108 lines
No EOL
3.7 KiB
YAML
108 lines
No EOL
3.7 KiB
YAML
name: Create and publish a Docker image
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, master ]
|
|
release:
|
|
types: [created, published, prereleased]
|
|
workflow_dispatch: # This allows manual triggering of the workflow
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
jobs:
|
|
build-and-push-image:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
id-token: write
|
|
attestations: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to the Container registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v4
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/lightning-pub
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
- name: Build and push Docker image
|
|
id: build-and-push
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: |
|
|
ghcr.io/${{ github.repository_owner }}/lightning-pub:latest
|
|
ghcr.io/${{ github.repository_owner }}/lightning-pub:master
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
- name: Capture image digest
|
|
id: capture-digest
|
|
run: |
|
|
# For multi-arch builds, use the digest from build output
|
|
DIGEST="${{ steps.build-and-push.outputs.digest }}"
|
|
echo "Multi-arch manifest digest: $DIGEST"
|
|
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
|
|
|
|
- name: Debug Print Digest
|
|
run: echo "Digest is ${{ steps.capture-digest.outputs.digest }}"
|
|
|
|
- name: Attest build provenance
|
|
uses: actions/attest-build-provenance@v1
|
|
with:
|
|
subject-digest: ${{ steps.capture-digest.outputs.digest }}
|
|
subject-name: ghcr.io/${{ github.repository_owner }}/lightning-pub
|
|
push-to-registry: true
|
|
|
|
- name: Trigger StartOS package build
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
|
|
env:
|
|
STARTOS_BUILD_TRIGGER: ${{ secrets.STARTOS_BUILD_TRIGGER }}
|
|
run: |
|
|
if [ -z "$STARTOS_BUILD_TRIGGER" ]; then
|
|
echo "⚠️ STARTOS_BUILD_TRIGGER not configured, skipping StartOS build trigger"
|
|
exit 0
|
|
fi
|
|
|
|
echo "🚀 Triggering StartOS package build with digest: ${{ steps.capture-digest.outputs.digest }}"
|
|
|
|
curl -X POST \
|
|
-H "Accept: application/vnd.github+json" \
|
|
-H "Authorization: Bearer $STARTOS_BUILD_TRIGGER" \
|
|
https://api.github.com/repos/shocknet/start9-LightningPub/dispatches \
|
|
-d "{
|
|
\"event_type\": \"docker-image-updated\",
|
|
\"client_payload\": {
|
|
\"docker_tag\": \"latest\",
|
|
\"digest\": \"${{ steps.capture-digest.outputs.digest }}\",
|
|
\"commit\": \"${{ github.sha }}\"
|
|
}
|
|
}"
|
|
|
|
echo "✓ StartOS build triggered" |