-
Notifications
You must be signed in to change notification settings - Fork 15
77 lines (61 loc) · 2.09 KB
/
main.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: build
on:
push:
branches:
- master
- devel
release:
types: [created]
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: "true"
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: '14'
- name: Build OSCAR-UI
run: npm install && npm run deploy_container
working-directory: ./ui
- name: Prepare docker buildx
id: prepare
run: |
DOCKER_HUB_IMAGE=grycap/oscar
GHCR_IMAGE=ghcr.io/grycap/oscar
DOCKER_PLATFORMS=linux/amd64,linux/arm64
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
if [[ $GITHUB_REF == refs/heads/devel ]]; then
TAGS="--tag ${DOCKER_HUB_IMAGE}:devel --tag ${GHCR_IMAGE}:devel"
else
TAGS="--tag ${DOCKER_HUB_IMAGE}:latest --tag ${GHCR_IMAGE}:latest"
fi
if [[ ! -z "$VERSION" ]]; then
TAGS="$TAGS --tag ${DOCKER_HUB_IMAGE}:${VERSION} --tag ${GHCR_IMAGE}:${VERSION}"
fi
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
--build-arg VERSION=${VERSION} \
--build-arg GIT_COMMIT=${GITHUB_SHA::8} \
${TAGS} --file Dockerfile .
- name: Set up Docker Buildx
uses: crazy-max/[email protected]
- name: Docker Hub login
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
- name: GHCR login
env:
GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
GHCR_PASSWORD: ${{ secrets.GHCR_PASSWORD }}
run: echo "${GHCR_PASSWORD}" | docker login ghcr.io --username "${GHCR_USERNAME}" --password-stdin
- name: Build and Push
run: docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
- name: Clear
if: always()
run: rm -f ${HOME}/.docker/config.json