All checks were successful
Docker image CD / build_and_push (push) Successful in 21m46s
- add cache - add step to send webhook to rebuild container
70 lines
2.1 KiB
YAML
70 lines
2.1 KiB
YAML
name: Docker image CD
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- '*.*.*'
|
|
branches:
|
|
- 'main'
|
|
pull_request:
|
|
branches:
|
|
- 'main'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build_and_push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Get Meta
|
|
id: meta
|
|
run: |
|
|
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
|
|
echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to DockerHub
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: gitea.suda.codes
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
context: .
|
|
# platforms: linux/amd64,linux/arm/v7,linux/arm64
|
|
platforms: linux/amd64
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: |
|
|
gitea.suda.codes/sudacode/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}
|
|
gitea.suda.codes/sudacode/${{ steps.meta.outputs.REPO_NAME }}:latest
|
|
cache-from: type=local,src=${{ runner.temp }}/.buildx-cache
|
|
cache-to: type=local,dest=${{ runner.temp }}/.buildx-cache-new,mode=max
|
|
|
|
- # Temp fix
|
|
# https://github.com/docker/build-push-action/issues/252
|
|
# https://github.com/moby/buildkit/issues/1896
|
|
name: Move cache
|
|
run: |
|
|
rm -rf ${{ runner.temp }}/.buildx-cache
|
|
mv ${{ runner.temp }}/.buildx-cache-new ${{ runner.temp }}/.buildx-cache
|
|
|
|
- name: Invoke deployment hook
|
|
uses: distributhor/workflow-webhook@v3
|
|
with:
|
|
webhook_url: ${{ secrets.WEBHOOK_URL }}
|
|
webhook_auth: ${{ secrets.WEBHOOK_AUTH }}
|
|
webhook_secret: ${{ secrets.WEBHOOK_SECRET }}
|
|
webhook_auth_type: bearer
|