Skip to content

Commit 0fef58f

Browse files
committed
fix: do not persist credentials in checkout action
1 parent 5cde7e9 commit 0fef58f

File tree

2 files changed

+73
-68
lines changed

2 files changed

+73
-68
lines changed

.github/actions/docker-build/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ runs:
4848
using: "composite"
4949
steps:
5050
- name: Checkout repository
51-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
51+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
52+
with:
53+
persist-credentials: false
5254

5355
- name: Set up QEMU
5456
if: inputs.setup-qemu == 'true'
Lines changed: 70 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,80 @@
11
name: Build and Test Docker Image
22

33
on:
4-
pull_request:
5-
branches: ["main"]
6-
workflow_dispatch:
4+
pull_request:
5+
branches: ["main"]
6+
workflow_dispatch:
77

88
jobs:
9-
should-test-docker-build:
10-
permissions:
11-
contents: read
12-
pull-requests: read
13-
name: Check if should `test_docker_build` run
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Check out the repo
17-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
9+
should-test-docker-build:
10+
permissions:
11+
contents: read
12+
pull-requests: read
13+
name: Check if should `test_docker_build` run
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out the repo
17+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
18+
with:
19+
persist-credentials: false
1820

19-
- name: Check if Dockerfile changed
20-
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
21-
id: docker-changes
22-
with:
23-
filters: |
24-
docker:
25-
- 'Dockerfile'
26-
- '.dockerignore'
27-
workflow:
28-
- ./.github/actions/docker-build/action.yml
29-
outputs:
30-
docker: ${{ steps.docker-changes.outputs.docker }}
31-
workflow: ${{ steps.docker-changes.outputs.workflow }}
21+
- name: Check if Dockerfile changed
22+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
23+
id: docker-changes
24+
with:
25+
filters: |
26+
docker:
27+
- 'Dockerfile'
28+
- '.dockerignore'
29+
workflow:
30+
- ./.github/actions/docker-build/action.yml
31+
- ./.github/workflows/build-test-docker.yml
32+
outputs:
33+
docker: ${{ steps.docker-changes.outputs.docker }}
34+
workflow: ${{ steps.docker-changes.outputs.workflow }}
3235

33-
test-docker-build:
34-
needs: [should-test-docker-build]
35-
name: Test Docker build ${{ matrix.arch }}
36-
runs-on: ubuntu-latest
37-
if: (needs.should-test-docker-build.outputs.workflow == 'true' || needs.should-test-docker-build.outputs.docker == 'true')
38-
permissions:
39-
contents: read
40-
packages: read
41-
strategy:
42-
matrix:
43-
include:
44-
- arch: amd64
45-
platform: linux/amd64
46-
image-name: build-amd64
47-
needs-qemu: false
48-
- arch: arm64
49-
platform: linux/arm64
50-
image-name: build-arm64
51-
needs-qemu: true
52-
steps:
53-
- name: Check out the repo
54-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
36+
test-docker-build:
37+
needs: [should-test-docker-build]
38+
name: Test Docker build ${{ matrix.arch }}
39+
runs-on: ubuntu-latest
40+
if: (needs.should-test-docker-build.outputs.workflow == 'true' || needs.should-test-docker-build.outputs.docker == 'true')
41+
permissions:
42+
contents: read
43+
packages: read
44+
strategy:
45+
matrix:
46+
include:
47+
- arch: amd64
48+
platform: linux/amd64
49+
image-name: build-amd64
50+
needs-qemu: false
51+
- arch: arm64
52+
platform: linux/arm64
53+
image-name: build-arm64
54+
needs-qemu: true
55+
steps:
56+
- name: Check out the repo
57+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
5558

56-
- name: Log in to GitHub Container Registry
57-
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
58-
with:
59-
registry: ghcr.io
60-
username: ${{ github.actor }}
61-
password: ${{ secrets.GITHUB_TOKEN }}
59+
- name: Log in to GitHub Container Registry
60+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
61+
with:
62+
registry: ghcr.io
63+
username: ${{ github.actor }}
64+
password: ${{ secrets.GITHUB_TOKEN }}
6265

63-
- name: Build image
64-
uses: ./.github/actions/docker-build
65-
with:
66-
context: .
67-
file: ./Dockerfile
68-
push: false
69-
load: true
70-
platforms: ${{ matrix.platform }}
71-
cache-from: type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-${{ matrix.arch }}
72-
image-name: ${{ matrix.image-name }}
73-
setup-qemu: ${{ matrix.needs-qemu }}
66+
- name: Build image
67+
uses: ./.github/actions/docker-build
68+
with:
69+
context: .
70+
file: ./Dockerfile
71+
push: false
72+
load: true
73+
platforms: ${{ matrix.platform }}
74+
cache-from: type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-${{ matrix.arch }}
75+
image-name: ${{ matrix.image-name }}
76+
setup-qemu: ${{ matrix.needs-qemu }}
7477

75-
- name: Test
76-
run: |
77-
docker run --platform ${{ matrix.platform }} --rm ${{ matrix.image-name }}:pr-${{ github.event.pull_request.number }} --version
78+
- name: Test
79+
run: |
80+
docker run --platform ${{ matrix.platform }} --rm ${{ matrix.image-name }}:pr-${{ github.event.pull_request.number }} --version

0 commit comments

Comments
 (0)