mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-22 05:40:50 +02:00
ci: enhance GitHub Actions workflow for Docker image publishing and add permissions
This commit is contained in:
parent
d2a21afcfe
commit
b68b16fb20
2 changed files with 106 additions and 7 deletions
110
.github/workflows/release-dev.yaml
vendored
110
.github/workflows/release-dev.yaml
vendored
|
@ -6,6 +6,12 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -33,18 +39,110 @@ jobs:
|
||||||
uses: codecov/codecov-action@v5
|
uses: codecov/codecov-action@v5
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
publish:
|
publish-docker-hub:
|
||||||
needs:
|
needs:
|
||||||
- build
|
- build
|
||||||
- test
|
- test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
# - uses: actions/checkout@v4
|
||||||
- name: Publish to Docker Hub
|
# - name: Publish to Docker Hub
|
||||||
uses: jerray/publish-docker-action@87d84711629b0dc9f6bb127b568413cc92a2088e #master@2022-10-14
|
# uses: jerray/publish-docker-action@87d84711629b0dc9f6bb127b568413cc92a2088e #master@2022-10-14
|
||||||
|
# with:
|
||||||
|
# username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
# password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
# file: dockerfiles/Dockerfile.self-contained
|
||||||
|
# repository: beatkind/watchtower
|
||||||
|
# tags: latest-dev
|
||||||
|
- name: Check out the repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Log in to Docker Hub
|
||||||
|
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
||||||
|
with:
|
||||||
|
images: beatkind/watchtower
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}}
|
||||||
|
org.opencontainers.image.authors={{github.actor}}
|
||||||
|
org.opencontainers.image.source={{repository}}
|
||||||
|
org.opencontainers.image.documentation=https://watchtower.devcdn.net
|
||||||
|
org.opencontainers.image.version=latest-dev
|
||||||
|
org.opencontainers.image.revision={{sha}}
|
||||||
|
org.opencontainers.image.vendor=beatkind
|
||||||
|
org.opencontainers.image.licenses=Apache-2.0
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest-dev
|
||||||
|
type=raw,value=${{ github.sha }}
|
||||||
|
type=raw,value=${{ github.ref_name }}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
id: push
|
||||||
|
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
file: dockerfiles/Dockerfile.self-contained
|
file: dockerfiles/Dockerfile.self-contained
|
||||||
repository: beatkind/watchtower
|
push: true
|
||||||
tags: latest-dev
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
|
- name: Generate artifact attestation
|
||||||
|
uses: actions/attest-build-provenance@v2
|
||||||
|
with:
|
||||||
|
subject-name: index.docker.io/beatkind/watchtower
|
||||||
|
subject-digest: ${{ steps.push.outputs.digest }}
|
||||||
|
push-to-registry: true
|
||||||
|
|
||||||
|
publish-github:
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Log in to the Container registry
|
||||||
|
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}}
|
||||||
|
org.opencontainers.image.authors={{github.actor}}
|
||||||
|
org.opencontainers.image.source={{repository}}
|
||||||
|
org.opencontainers.image.documentation=https://watchtower.devcdn.net
|
||||||
|
org.opencontainers.image.version=latest-dev
|
||||||
|
org.opencontainers.image.revision={{sha}}
|
||||||
|
org.opencontainers.image.vendor=beatkind
|
||||||
|
org.opencontainers.image.licenses=Apache-2.0
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest-dev
|
||||||
|
type=raw,value=${{ github.sha }}
|
||||||
|
type=raw,value=${{ github.ref_name }}
|
||||||
|
- name: Build and push Docker image
|
||||||
|
id: push
|
||||||
|
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: dockerfiles/Dockerfile.self-contained
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
- name: Generate artifact attestation
|
||||||
|
uses: actions/attest-build-provenance@v2
|
||||||
|
with:
|
||||||
|
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
|
||||||
|
subject-digest: ${{ steps.push.outputs.digest }}
|
||||||
|
push-to-registry: true
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -14,3 +14,4 @@ docs/assets/*.wasm
|
||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
|
|
||||||
.env
|
.env
|
||||||
|
.venv
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue