New feature to support mysql migration #46
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: Docker Build | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- '*' | |
pull_request: | |
branches: | |
- '*' | |
tags: | |
- '*' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build-and-push-docker-image: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Log into registry ${{ env.REGISTRY }} | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup Docker buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v2 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Get current date | |
id: date | |
run: | | |
echo "datetime=$(date +'%Y%m%d-%H%M%S')" >> $GITHUB_ENV | |
- name: Build and Push Versioned Docker Image | |
id: build-and-push | |
uses: docker/build-push-action@v2 | |
if: startsWith(github.ref, 'refs/pull/') | |
with: | |
context: . | |
push: true | |
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.base_ref }}_${{ env.datetime }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Build and Push Latest Docker Image | |
id: build-and-push-latest | |
uses: docker/build-push-action@v2 | |
if: ${{ github.ref == 'refs/heads/master' }} | |
with: | |
context: . | |
push: true | |
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
labels: ${{ steps.meta.outputs.labels }} |