Skip to content

Commit 6b63145

Browse files
authored
Only docker auth when pushing (#57)
1 parent 64cd8ac commit 6b63145

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ jobs:
3636
runs-on: ubuntu-24.04
3737

3838
permissions:
39-
contents: 'read'
40-
id-token: 'write'
39+
contents: "read"
40+
id-token: "write"
4141

4242
env:
43-
IMAGE_NAME: 'hexdocs'
44-
PROJECT_ID: 'hexpm-prod'
43+
IMAGE_NAME: "hexdocs"
44+
PROJECT_ID: "hexpm-prod"
4545
SERVICE_ACCOUNT: ${{ secrets.GCLOUD_SERVICE_ACCOUNT }}
4646
WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCLOUD_WORKFLOW_IDENTITY_POOL_PROVIDER }}
4747

@@ -59,20 +59,22 @@ jobs:
5959

6060
- name: Google auth
6161
id: auth
62-
uses: 'google-github-actions/auth@v2'
62+
uses: "google-github-actions/auth@v2"
63+
if: ${{ github.event_name != 'pull_request' }}
6364
with:
64-
token_format: 'access_token'
65+
token_format: "access_token"
6566
project_id: ${{ env.PROJECT_ID }}
6667
service_account: ${{ env.SERVICE_ACCOUNT }}
6768
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }}
6869

6970
- name: Docker Auth
7071
id: docker-auth
71-
uses: 'docker/login-action@v3'
72+
uses: "docker/login-action@v3"
73+
if: ${{ github.event_name != 'pull_request' }}
7274
with:
7375
registry: gcr.io
74-
username: 'oauth2accesstoken'
75-
password: '${{ steps.auth.outputs.access_token }}'
76+
username: "oauth2accesstoken"
77+
password: "${{ steps.auth.outputs.access_token }}"
7678

7779
- name: Build and push
7880
uses: docker/build-push-action@v6

0 commit comments

Comments
 (0)