Skip to content

Commit 7e01744

Browse files
committed
Use job token where possible
It's possible if you set permissions packages:write and specify the image name explicitly
1 parent 3202d05 commit 7e01744

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
workflow_dispatch:
88

99
concurrency: testing
10+
permissions:
11+
contents: read
12+
packages: write
1013
jobs:
1114
add_temp_pkgs1:
1215
name: Add temporary packages for testing
@@ -23,7 +26,7 @@ jobs:
2326
uses: docker/login-action@v3
2427
with:
2528
registry: ghcr.io
26-
username: ${{ github.actor }}
29+
username: ${{ github.repository_owner }}
2730
password: ${{ secrets.GITHUB_TOKEN }}
2831
- name: lower case repository_owner
2932
id: lower_case_repository_owner
@@ -56,7 +59,7 @@ jobs:
5659
uses: docker/login-action@v3
5760
with:
5861
registry: ghcr.io
59-
username: ${{ github.actor }}
62+
username: ${{ github.repository_owner }}
6063
password: ${{ secrets.GITHUB_TOKEN }}
6164
- name: lower case repository_owner
6265
id: lower_case_repository_owner
@@ -82,12 +85,12 @@ jobs:
8285
- uses: actions/checkout@v4
8386
- name: Set up Docker Buildx
8487
uses: docker/setup-buildx-action@v3
85-
- name: Login to GitHub Container Registry with PAT_TOKEN
88+
- name: Login to GitHub Container Registry
8689
uses: docker/login-action@v3
8790
with:
8891
registry: ghcr.io
89-
username: ${{ github.actor }}
90-
password: ${{ secrets.PAT_TOKEN }}
92+
username: ${{ github.repository_owner }}
93+
password: ${{ secrets.GITHUB_TOKEN }}
9194
- uses: ./
9295
with:
9396
token: ${{ secrets.PAT_TOKEN }}
@@ -120,7 +123,7 @@ jobs:
120123
- uses: actions/checkout@v4
121124
- uses: ./
122125
with:
123-
token: ${{ secrets.PAT_TOKEN }}
126+
token: ${{ secrets.GITHUB_TOKEN }}
124127
repository_owner: ${{ github.repository_owner }}
125128
repository: ${{ github.repository }}
126129
package_name: p1

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ delete all / untagged ghcr containers in a repository
129129
- name: Delete all containers from package without tags
130130
uses: Chizkiyahu/delete-untagged-ghcr-action@v2
131131
with:
132-
token: ${{ secrets.PAT_TOKEN }}
132+
token: ${{ github.token }}
133133
repository_owner: ${{ github.repository_owner }}
134134
repository: ${{ github.repository }}
135135
package_name: the-package-name
@@ -145,12 +145,12 @@ delete all / untagged ghcr containers in a repository
145145
uses: docker/login-action@v2
146146
with:
147147
registry: ghcr.io
148-
username: ${{ github.actor }}
149-
password: ${{ secrets.PAT_TOKEN }}
148+
username: ${{ github.repository_owner }}
149+
password: ${{ github.token }}
150150
- name: Delete all containers from package without tags
151151
uses: Chizkiyahu/delete-untagged-ghcr-action@v2
152152
with:
153-
token: ${{ secrets.PAT_TOKEN }}
153+
token: ${{ github.token }}
154154
repository_owner: ${{ github.repository_owner }}
155155
repository: ${{ github.repository }}
156156
package_name: the-package-name
@@ -164,7 +164,7 @@ delete all / untagged ghcr containers in a repository
164164
- name: Delete all containers from package
165165
uses: Chizkiyahu/delete-untagged-ghcr-action@v2
166166
with:
167-
token: ${{ secrets.PAT_TOKEN }}
167+
token: ${{ github.token }}
168168
repository_owner: ${{ github.repository_owner }}
169169
repository: ${{ github.repository }}
170170
package_name: the-package-name

0 commit comments

Comments
 (0)