|
1 |
| -# This workflow uses actions that are not certified by GitHub. |
2 |
| -# They are provided by a third-party and are governed by |
3 |
| -# separate terms of service, privacy policy, and support |
4 |
| -# documentation. |
5 |
| - |
6 |
| -name: Publish Docker image |
| 1 | +name: Deploy |
7 | 2 |
|
8 | 3 | on:
|
9 |
| - release: |
10 |
| - types: [published] |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main # Adjust as per your branch requirements |
11 | 7 |
|
12 | 8 | jobs:
|
13 |
| - push_to_registry: |
14 |
| - name: Push Docker image to Docker Hub |
| 9 | + deploy: |
15 | 10 | runs-on: ubuntu-latest
|
16 |
| - permissions: |
17 |
| - packages: write |
18 |
| - contents: read |
19 |
| - attestations: write |
20 |
| - id-token: write |
21 | 11 | steps:
|
22 |
| - - name: Check out the repo |
23 |
| - uses: actions/checkout@v4 |
24 |
| - |
25 |
| - - name: Log in to Docker Hub |
26 |
| - uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a |
27 |
| - with: |
28 |
| - username: ${{ secrets.DOCKER_USERNAME }} |
29 |
| - password: ${{ secrets.DOCKER_PASSWORD }} |
30 |
| - |
31 |
| - - name: Extract metadata (tags, labels) for Docker |
32 |
| - id: meta |
33 |
| - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
| 12 | + - name: Login to Docker Hub |
| 13 | + uses: docker/login-action@v3 |
34 | 14 | with:
|
35 |
| - images: my-docker-hub-namespace/my-docker-hub-repository |
| 15 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 16 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
36 | 17 |
|
37 |
| - - name: Build and push Docker image |
38 |
| - id: push |
39 |
| - uses: docker/build-push-action@v5.3.0 |
| 18 | + - name: Build and push |
| 19 | + uses: docker/build-push-action@v5 |
40 | 20 | with:
|
41 |
| - context: . |
42 |
| - file: ./Dockerfile |
43 | 21 | push: true
|
44 |
| - tags: ${{ steps.meta.outputs.tags }} |
45 |
| - labels: ${{ steps.meta.outputs.labels }} |
46 |
| - |
47 |
| - - name: Generate artifact attestation |
48 |
| - uses: actions/attest-build-provenance@v1 |
49 |
| - with: |
50 |
| - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
51 |
| - subject-digest: ${{ steps.push.outputs.digest }} |
52 |
| - push-to-registry: true |
| 22 | + tags: ${{ secrets.DOCKERHUB_USERNAME }}/my-image:latest |
0 commit comments