Skip to content

ci: trigger cluster image-update on master build #6

ci: trigger cluster image-update on master build

ci: trigger cluster image-update on master build #6

Workflow file for this run

name: Docker Build and Publish
on:
push:
branches:
- master
- '**'
paths-ignore:
- '.gitignore'
- 'docker-compose*.yml'
- '*.md'
- '!docs/**/*.md'
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
run: |
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
TAGS="ghcr.io/invoiceshelf/docs:$SHORT_SHA"
if [ "${{ github.ref }}" == "refs/heads/master" ]; then
TAGS="$TAGS,ghcr.io/invoiceshelf/docs:latest"
fi
echo "tags=$TAGS" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
trigger-deployment:
runs-on: ubuntu-latest
needs: build-and-push
# Only the master build pushes :latest, so only it should bump the cluster.
if: github.ref == 'refs/heads/master'
steps:
- name: Trigger k8s deployment update
env:
GHCR_PAT: ${{ secrets.GHCR_PAT }}
run: |
if [ -n "$GHCR_PAT" ]; then
curl -X POST \
-H "Authorization: token $GHCR_PAT" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/ideologix/k8s-production-cluster/dispatches \
-d '{"event_type":"image-pushed"}'
fi