Skip to content

Commit 96f768b

Browse files
committed
feat: publish to github registry instead of dockerhub
1 parent 46102fd commit 96f768b

File tree

1 file changed

+33
-23
lines changed

1 file changed

+33
-23
lines changed

.github/workflows/publish.yml

+33-23
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,49 @@ on:
55
tags:
66
- 'v*.*.*'
77

8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
812
jobs:
913
deployment:
1014
name: Deployment
1115
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
attestations: write
20+
id-token: write
1221
environment: production
1322
steps:
14-
- name: Docker meta
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Log in to the Container registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Extract metadata (tags, labels) for Docker
1534
id: meta
1635
uses: docker/metadata-action@v5
1736
with:
18-
# list of Docker images to use as base name for tags
19-
images: |
20-
appsinet/php_development
21-
# generate Docker tags based on the following events/attributes
22-
tags: |
23-
type=schedule,pattern={{date 'YYYYMMDD'}}
24-
type=ref,event=tag
25-
type=semver,pattern={{version}}
26-
type=semver,pattern={{major}}.{{minor}}
27-
type=semver,pattern={{major}}
28-
type=sha
37+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
2938

30-
- name: Set up Docker Buildx
31-
uses: docker/setup-buildx-action@v3
32-
33-
- name: Login to DockerHub
34-
uses: docker/login-action@v3
39+
- name: Build and push Docker image
40+
id: push
41+
uses: docker/build-push-action@v5
3542
with:
36-
username: ${{ secrets.DOCKERHUB_USERNAME }}
37-
password: ${{ secrets.DOCKERHUB_TOKEN }}
43+
context: .
44+
push: true
45+
tags: ${{ steps.meta.outputs.tags }}
46+
labels: ${{ steps.meta.outputs.labels }}
3847

39-
- name: Build and push
40-
uses: docker/build-push-action@v5
48+
- name: Generate artifact attestation
49+
uses: actions/attest-build-provenance@v2
4150
with:
42-
push: ${{ github.event_name != 'pull_request' }}
43-
tags: ${{ steps.meta.outputs.tags }}
51+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
52+
subject-digest: ${{ steps.push.outputs.digest }}
53+
push-to-registry: true

0 commit comments

Comments
 (0)