Skip to content

Commit ef95667

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 d06b930 commit ef95667

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
@@ -5,6 +5,9 @@ on:
55
pull_request:
66
branches: [ main ]
77
concurrency: testing
8+
permissions:
9+
contents: read
10+
packages: write
811
jobs:
912
add_temp_pkgs1:
1013
name: Add temporary packages for testing
@@ -21,7 +24,7 @@ jobs:
2124
uses: docker/login-action@v2
2225
with:
2326
registry: ghcr.io
24-
username: ${{ github.actor }}
27+
username: ${{ github.repository_owner }}
2528
password: ${{ secrets.GITHUB_TOKEN }}
2629
- name: lower case repository_owner
2730
id: lower_case_repository_owner
@@ -54,7 +57,7 @@ jobs:
5457
uses: docker/login-action@v2
5558
with:
5659
registry: ghcr.io
57-
username: ${{ github.actor }}
60+
username: ${{ github.repository_owner }}
5861
password: ${{ secrets.GITHUB_TOKEN }}
5962
- name: lower case repository_owner
6063
id: lower_case_repository_owner
@@ -80,12 +83,12 @@ jobs:
8083
- uses: actions/checkout@v3
8184
- name: Set up Docker Buildx
8285
uses: docker/setup-buildx-action@v2
83-
- name: Login to GitHub Container Registry with PAT_TOKEN
86+
- name: Login to GitHub Container Registry
8487
uses: docker/login-action@v2
8588
with:
8689
registry: ghcr.io
87-
username: ${{ github.actor }}
88-
password: ${{ secrets.PAT_TOKEN }}
90+
username: ${{ github.repository_owner }}
91+
password: ${{ secrets.GITHUB_TOKEN }}
8992
- uses: ./
9093
with:
9194
token: ${{ secrets.PAT_TOKEN }}
@@ -118,7 +121,7 @@ jobs:
118121
- uses: actions/checkout@v3
119122
- uses: ./
120123
with:
121-
token: ${{ secrets.PAT_TOKEN }}
124+
token: ${{ secrets.GITHUB_TOKEN }}
122125
repository_owner: ${{ github.repository_owner }}
123126
repository: ${{ github.repository }}
124127
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)