forked from morganzero/cloudflare-companion
-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (81 loc) · 2.97 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
name: Image Release to GitHub Container Registry
on:
# Run the workflow every two sundays at 8:00 UTC
schedule:
- cron: "0 8 */14 * 0"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Trigger the workflow on new releases
release:
types: [published]
# Trigger the workflow on push or pull request when the
# Dockerfile is updated or the dependencies are updated
pull_request:
branches: [main]
paths:
- Dockerfile
- requirements.lock
- pyproject.toml
- src/dns_synchub/dns_synchub/__about__.py
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
attestations: write
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up QEMU to build multi-platform images
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@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute Environment Variables
run: |
echo "VERSION=$(grep -Po '(?<=^__version__ = ")[^"]*' src/dns_synchub/__about__.py)" >> "$GITHUB_ENV"
echo "PYTHON_VERSION=$(cat .python-version)" >> "$GITHUB_ENV"
shell: bash
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{major}},value=v${{ env.VERSION }},enable=${{ !startsWith(env.VERSION, '0') }}
type=semver,pattern={{major}}.{{minor}},value=v${{ env.VERSION }}
type=semver,pattern={{version}},value=v${{ env.VERSION }}
- name: Build and Push image
id: push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
push: ${{ !env.ACT && github.event_name != 'pull_request' }}
build-args: |
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
# Skip step because unsupported env variable: ACTIONS_ID_TOKEN_REQUEST_URL
# See https://github.com/nektos/act/issues/329
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
if: ${{ !env.ACT && github.event_name != 'pull_request' }}
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true