1.1.3 #71
Workflow file for this run
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 | |
on: | |
# Only on tagged release | |
release: | |
types: [published, edited] | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Set up Docker buildx cache | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Docker image tags | |
run: | | |
echo 'DOCKER_IMAGE_TAGS<<EOF' >> $GITHUB_ENV | |
# Add release tag if it matches pattern (e.g. 0.0.1) | |
if [[ ${{ github.ref_name }} =~ .+\..+\..+ ]]; then | |
echo ",ghcr.io/${{ github.repository }}:${{ github.ref_name }}" >> $GITHUB_ENV | |
fi | |
# Only add latest tag if master branch | |
if [[ ${{ github.ref_name }} == 'master' ]]; then | |
echo ",ghcr.io/${{ github.repository }}:latest" >> $GITHUB_ENV | |
fi | |
echo 'EOF' >> $GITHUB_ENV | |
# Only build and push Docker images for releases | |
- name: Build and push Docker image to GitHub Container Registry | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: ${{ env.DOCKER_IMAGE_TAGS }} | |
build-args: | | |
git_commit_id=${{ github.sha }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new | |
- name: Update Docker buildx cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |