Skip to content

Merge pull request #256 from grycap/dev-gmolto #553

Merge pull request #256 from grycap/dev-gmolto

Merge pull request #256 from grycap/dev-gmolto #553

Workflow file for this run

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/ghaction-docker-buildx@v3.1.0
- 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