Skip to content

Commit

Permalink
ci: refactor Docker setup to use GitHub token instead of CR_PAT
Browse files Browse the repository at this point in the history
- Removed `CR_PAT` as a required input in Docker setup steps and replaced it with Github token for logging into the GitHub Container Registry.
- Added explicit permissions for GitHub token in Docker publish actions specifying 'read' for 'contents' and 'write' for 'packages'.
- Removed `CR_PAT` from the secrets list in Docker publish actions.
- Updated comment about managing Github Actions access in the container settings for GitHub Container Registry login step.

Signed-off-by: 陳鈞 <[email protected]>
  • Loading branch information
jim60105 committed May 4, 2024
1 parent 8df0d59 commit 0277c27
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/docker-reused-setup-steps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ inputs:
required: true
QUAY_TOKEN:
required: true
CR_PAT:
required: true
tag:
required: true

Expand Down Expand Up @@ -55,14 +53,13 @@ runs:
username: ${{ inputs.DOCKERHUB_USERNAME }}
password: ${{ inputs.DOCKERHUB_TOKEN }}

# Create a Access Token with `read:packages` and `write:packages` scopes
# CR_PAT
# You may need to manage write and read access of GitHub Actions for repositories in the container settings.
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ inputs.CR_PAT }}
password: ${{ github.token }}

- name: Login to Quay Container Registry
uses: docker/login-action@v3
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/docker_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:

workflow_dispatch:

# Sets the permissions granted to the GITHUB_TOKEN for the actions in this job.
permissions:
contents: read
packages: write

jobs:
docker-alpine:
runs-on: ubuntu-latest
Expand All @@ -23,7 +28,6 @@ jobs:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
CR_PAT: ${{ secrets.CR_PAT }}
tag: alpine

- name: Build and push
Expand Down Expand Up @@ -53,7 +57,6 @@ jobs:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
CR_PAT: ${{ secrets.CR_PAT }}
tag: ubi

- name: Build and push
Expand Down Expand Up @@ -83,7 +86,6 @@ jobs:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
CR_PAT: ${{ secrets.CR_PAT }}
tag: distroless

- name: Build and push
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/docker_publish_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:

workflow_dispatch:

# Sets the permissions granted to the GITHUB_TOKEN for the actions in this job.
permissions:
contents: read
packages: write

jobs:
docker-latest:
runs-on: ubuntu-latest
Expand All @@ -25,7 +30,6 @@ jobs:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
CR_PAT: ${{ secrets.CR_PAT }}
tag: latest

- name: Build and push
Expand Down

0 comments on commit 0277c27

Please sign in to comment.