Skip to content

Commit 4b29f61

Browse files
Create docker-publish.yml
1 parent ca32242 commit 4b29f61

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

.github/workflows/docker-publish.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Publish Docker image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
env:
8+
REGISTRY: docker.io
9+
IMAGE_NAME: saitejamadha/discord-js-bot
10+
11+
jobs:
12+
push_to_registry:
13+
name: Push Docker image to Docker Hub
14+
runs-on: ubuntu-latest
15+
permissions:
16+
packages: write
17+
contents: read
18+
attestations: write
19+
id-token: write
20+
steps:
21+
- name: Check out the repo
22+
uses: actions/checkout@v4
23+
24+
- name: Log in to Docker Hub
25+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
26+
with:
27+
username: ${{ secrets.DOCKER_USERNAME }}
28+
password: ${{ secrets.DOCKER_PASSWORD }}
29+
30+
- name: Extract metadata (tags, labels) for Docker
31+
id: meta
32+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
33+
with:
34+
images: my-docker-hub-namespace/my-docker-hub-repository
35+
36+
- name: Build and push Docker image
37+
id: push
38+
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
39+
with:
40+
context: .
41+
file: ./Dockerfile
42+
push: true
43+
tags: ${{ steps.meta.outputs.tags }}
44+
labels: ${{ steps.meta.outputs.labels }}
45+
46+
- name: Generate artifact attestation
47+
uses: actions/attest-build-provenance@v1
48+
with:
49+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
50+
subject-digest: ${{ steps.push.outputs.digest }}
51+
push-to-registry: true

0 commit comments

Comments
 (0)