Skip to content

Commit 6f559e1

Browse files
authored
ci: improve security by using GHA environments (#2335)
1 parent 359eca3 commit 6f559e1

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

.github/workflows/docker.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ jobs:
8080
VERSION: ${{ (github.ref_type == 'tag' && github.ref_name) || steps.check.outputs.ref || 'dev' }}
8181
PHP_VERSION: ${{ steps.check.outputs.php_version }}
8282
build:
83+
environment: dockerhub
8384
runs-on: ${{ startsWith(matrix.platform, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
8485
needs:
8586
- prepare
@@ -129,8 +130,8 @@ jobs:
129130
uses: docker/login-action@v4
130131
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
131132
with:
132-
username: ${{ secrets.REGISTRY_USERNAME }}
133-
password: ${{ secrets.REGISTRY_PASSWORD }}
133+
username: ${{ vars.DOCKERHUB_USERNAME }}
134+
password: ${{ secrets.DOCKERHUB_TOKEN }}
134135
- name: Build
135136
id: build
136137
uses: docker/bake-action@v7
@@ -204,6 +205,7 @@ jobs:
204205

205206
# Adapted from https://docs.docker.com/build/ci/github-actions/multi-platform/
206207
push:
208+
environment: dockerhub
207209
runs-on: ubuntu-24.04
208210
needs:
209211
- prepare
@@ -227,8 +229,8 @@ jobs:
227229
uses: docker/login-action@v4
228230
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
229231
with:
230-
username: ${{ secrets.REGISTRY_USERNAME }}
231-
password: ${{ secrets.REGISTRY_PASSWORD }}
232+
username: ${{ vars.DOCKERHUB_USERNAME }}
233+
password: ${{ secrets.DOCKERHUB_TOKEN }}
232234
- name: Create manifest list and push
233235
working-directory: /tmp/metadata
234236
run: |

.github/workflows/docs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ concurrency:
1616
cancel-in-progress: true
1717
jobs:
1818
deploy:
19+
environment: website
1920
runs-on: ubuntu-slim
2021
steps:
2122
- name: Trigger website deployment

.github/workflows/static.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ jobs:
8484
VERSION: ${{ steps.check.outputs.ref || 'dev' }}
8585

8686
build-linux-musl:
87+
environment: dockerhub
8788
permissions:
8889
contents: write
8990
id-token: write
@@ -121,8 +122,8 @@ jobs:
121122
uses: docker/login-action@v4
122123
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
123124
with:
124-
username: ${{ secrets.REGISTRY_USERNAME }}
125-
password: ${{ secrets.REGISTRY_PASSWORD }}
125+
username: ${{ vars.DOCKERHUB_USERNAME }}
126+
password: ${{ secrets.DOCKERHUB_TOKEN }}
126127
- name: Set VERSION
127128
run: |
128129
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then
@@ -219,6 +220,7 @@ jobs:
219220
BINARY: ./frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}${{ matrix.debug && '-debug' || '' }}${{ matrix.mimalloc && '-mimalloc' || '' }}
220221

221222
build-linux-gnu:
223+
environment: dockerhub
222224
permissions:
223225
contents: write
224226
id-token: write
@@ -289,8 +291,8 @@ jobs:
289291
uses: docker/login-action@v4
290292
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
291293
with:
292-
username: ${{ secrets.REGISTRY_USERNAME }}
293-
password: ${{ secrets.REGISTRY_PASSWORD }}
294+
username: ${{ vars.DOCKERHUB_USERNAME }}
295+
password: ${{ secrets.DOCKERHUB_TOKEN }}
294296
- name: Build
295297
id: build
296298
uses: docker/bake-action@v7
@@ -377,6 +379,7 @@ jobs:
377379

378380
# Adapted from https://docs.docker.com/build/ci/github-actions/multi-platform/
379381
push:
382+
environment: dockerhub
380383
runs-on: ubuntu-24.04
381384
needs:
382385
- prepare
@@ -402,8 +405,8 @@ jobs:
402405
uses: docker/login-action@v4
403406
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
404407
with:
405-
username: ${{ secrets.REGISTRY_USERNAME }}
406-
password: ${{ secrets.REGISTRY_PASSWORD }}
408+
username: ${{ vars.DOCKERHUB_USERNAME }}
409+
password: ${{ secrets.DOCKERHUB_TOKEN }}
407410
- name: Create manifest list and push
408411
working-directory: /tmp/metadata
409412
run: |

.github/workflows/translate.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ permissions:
1313
pull-requests: write
1414
jobs:
1515
build:
16+
environment: translate
1617
name: Translate Docs
1718
runs-on: ubuntu-latest
1819
steps:

0 commit comments

Comments
 (0)