diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 00000000..73a529fa --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,49 @@ +name: build + +on: + push: + branches: master + release: + +jobs: + buildx: + runs-on: ubuntu-18.04 + steps: + - name: Checkout + uses: actions/checkout@v2.2.0 + + - name: Prepare + id: prepare + run: | + DOCKER_IMAGE=grycap/oscar + DOCKER_PLATFORMS=linux/amd64,linux/arm64 + + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/v} + fi + + TAGS="--tag ${DOCKER_IMAGE}:latest" + if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + TAGS="$TAGS --tag ${DOCKER_IMAGE}:${VERSION}" + fi + + echo ::set-output name=docker_image::${DOCKER_IMAGE} + echo ::set-output name=version::${VERSION} + echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ + --build-arg VERSION=${VERSION} \ + --build-arg GIT_COMMIT=${GITHUB_SHA::8} \ + ${TAGS} . + + - name: Login + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + + - name: Build and Push + run: docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} + + - name: Clear + run: rm -f ${HOME}/.docker/config.json + +