Skip to content

Workflow file for this run

name: Build and push docker image for branch or tag
on:
release:
types: [ released ]
push:
branches: ['**']
jobs:
build-zxcvbn-i18n-api-container:
name: Build zxcvbn-i18n-api container
runs-on: ubuntu-latest
if: github.repository == 'ScientaNL/zxcvbn-i18n-api'
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Set Github environment variables
uses: ScientaNL/[email protected]
- name: Checkout repository
uses: actions/checkout@v3
- name: DockerHub Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_PUBLIC_USERNAME }}
password: ${{ secrets.DOCKERHUB_PUBLIC_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build & push Docker image for branch
if: github.event_name == 'push'
uses: docker/build-push-action@v3
with:
push: true
tags: scienta/zxcvbn-i18n-api:branch-${{env.GITHUB_REF_NAME_SLUG}}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
- API_VERSION=${{env.GITHUB_REF_NAME_SLUG}}-${{env.GITHUB_SHA_SHORT}}
- name: Build & push Docker image for release
if: github.event_name == 'release'
uses: docker/build-push-action@v3
with:
push: true
tags: scienta/zxcvbn-i18n-api:${{env.GITHUB_REF_NAME_SLUG}}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
- API_VERSION=${{env.GITHUB_REF_NAME_SLUG}}