Update github actions #3
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: functions build and publish | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: | |
- "*" | |
jobs: | |
docker-build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
with: | |
fetch-depth: 1 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@master | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@master | |
- name: Get TAG | |
id: get_tag | |
run: echo TAG=${{ github.sha }} >> $GITHUB_ENV | |
- name: Login to Docker Hub | |
uses: docker/login-action@master | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Cache Docker layers | |
uses: actions/cache@master | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Build and export to Docker | |
uses: docker/build-push-action@master | |
with: | |
context: . | |
file: ./Dockerfile | |
load: true | |
tags: ${{ env.TEST_TAG }} | |
- name: Build | |
uses: docker/build-push-action@master | |
with: | |
context: . | |
file: ./Dockerfile | |
push: false | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max | |
tags: | | |
${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:latest | |
${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:${{ env.TAG }} | |
docker-push: | |
if: ${{ github.ref == 'refs/heads/main' }} | |
needs: docker-build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
with: | |
fetch-depth: 1 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@master | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@master | |
- name: Get TAG | |
id: get_tag | |
run: echo TAG=${{ github.sha }} >> $GITHUB_ENV | |
- name: Login to Docker Hub | |
uses: docker/login-action@master | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Cache Docker layers | |
uses: actions/cache@master | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Push to Registry | |
uses: docker/build-push-action@master | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max | |
tags: | | |
${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:latest | |
${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:${{ env.TAG }} | |
- | |
# Temp fix | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |