Update workflows #171
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: Deploy | |
on: | |
push: | |
branches: [ master ] | |
paths-ignore: | |
- 'README.md' | |
- 'LICENSE' | |
concurrency: | |
group: deploy | |
cancel-in-progress: true | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
analyze: | |
uses: ./.github/workflows/analyze.yml | |
test: | |
needs: analyze | |
uses: ./.github/workflows/test.yml | |
docker: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to Docker registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: type=raw,value=latest,enable={{is_default_branch}} | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./ | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new | |
- # Temp fix for caches are copied over the existing cache so it keeps growing currently. | |
# 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 | |
deploy: | |
needs: docker | |
runs-on: ubuntu-latest | |
steps: | |
- name: Trigger deployment webhook | |
uses: distributhor/workflow-webhook@v2 | |
env: | |
webhook_url: ${{ secrets.WEBHOOK_URL }} | |
webhook_secret: ${{ secrets.WEBHOOK_SECRET }} | |
webhook_type: "json" | |
silent: true |