Skip to content

Commit 10266b6

Browse files
author
mithmith
committed
2 parents cafe04d + ec4e082 commit 10266b6

File tree

1 file changed

+45
-27
lines changed

1 file changed

+45
-27
lines changed

.github/workflows/docker.yml

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,53 @@
1-
name: Build and Publish Docker Image
1+
name: Build and Push Docker Image
22

33
on:
4-
push:
5-
tags:
6-
- "v*" # Триггер для версии, например, v1.0.0
7-
workflow_dispatch: # Ручной запуск workflow
4+
push:
5+
branches:
6+
- '*'
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
810

911
jobs:
10-
build-and-push:
11-
name: Build and Push Docker Image
12-
runs-on: ubuntu-latest
12+
build:
13+
runs-on: ubuntu-latest
1314

14-
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v3
15+
permissions:
16+
contents: read
17+
packages: write
18+
attestations: write
19+
id-token: write
1720

18-
- name: Log in to Docker Hub
19-
uses: docker/login-action@v2
20-
with:
21-
username: ${{ secrets.DOCKER_USERNAME }}
22-
password: ${{ secrets.DOCKER_PASSWORD }}
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
2324

24-
- name: Extract version from tag
25-
id: extract_version
26-
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
25+
- name: Log in to the Container registry
26+
uses: docker/[email protected]
27+
with:
28+
registry: ${{ env.REGISTRY }}
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Extract metadata (tags, labels) for Docker
33+
id: meta
34+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
35+
with:
36+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
37+
38+
- name: Build and push Docker image
39+
id: push
40+
uses: docker/[email protected]
41+
with:
42+
context: .
43+
file: ./dockerfile
44+
push: true
45+
tags: ${{ steps.meta.outputs.tags }}
46+
labels: ${{ steps.meta.outputs.labels }}
2747

28-
- name: Build and Push Docker Image
29-
uses: docker/build-push-action@v4
30-
with:
31-
context: .
32-
push: true
33-
tags: |
34-
your_dockerhub_username/youtube_node_downloader:${{ env.VERSION }}
35-
your_dockerhub_username/youtube_node_downloader:latest
48+
- name: Generate artifact attestation
49+
uses: actions/attest-build-provenance@v2
50+
with:
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)