Merge pull request #273 from grycap/fix-esparig #568
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |