Skip to content

Commit 20e04a3

Browse files
authored
Update docker-publish.yml
1 parent 047c8f0 commit 20e04a3

File tree

1 file changed

+15
-36
lines changed

1 file changed

+15
-36
lines changed

.github/workflows/docker-publish.yml

+15-36
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,44 @@
1-
# .github/workflows/docker-publish.yml
2-
name: Build and Publish Docker Image
1+
name: Create and publish Docker image
32

43
on:
54
push:
6-
branches: [ main ]
7-
paths:
8-
- 'environment.yml'
9-
- 'apt.txt'
10-
- 'Dockerfile'
11-
workflow_dispatch:
5+
branches: ['main']
6+
pull_request:
7+
branches: ['main']
128

139
env:
1410
REGISTRY: ghcr.io
15-
ORGANIZATION: UW-GDA
1611
IMAGE_NAME: ${{ github.repository }}
1712

1813
jobs:
19-
build-and-push:
14+
build-and-push-image:
2015
runs-on: ubuntu-latest
21-
# Ensure the job runs within the organization context
22-
if: github.repository_owner == 'UW-GDA'
23-
2416
permissions:
2517
contents: read
2618
packages: write
27-
attestations: write
28-
id-token: write
29-
19+
3020
steps:
3121
- name: Checkout repository
3222
uses: actions/checkout@v4
33-
34-
- name: Log in to GitHub Container Registry
23+
24+
- name: Log in to the Container registry
25+
if: github.event_name != 'pull_request'
3526
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
3627
with:
3728
registry: ${{ env.REGISTRY }}
3829
username: ${{ github.actor }}
39-
password: ${{ secrets.TOKEN_GITHUB }}
40-
41-
- name: Extract Docker metadata
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Extract metadata (tags, labels) for Docker
4233
id: meta
4334
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
4435
with:
4536
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
46-
tags: |
47-
type=sha,format=long
48-
type=ref,event=branch
49-
type=raw,value=latest,enable={{is_default_branch}}
50-
37+
5138
- name: Build and push Docker image
52-
id: push
53-
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
39+
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
5440
with:
5541
context: .
56-
push: true
42+
push: ${{ github.event_name != 'pull_request' }}
5743
tags: ${{ steps.meta.outputs.tags }}
5844
labels: ${{ steps.meta.outputs.labels }}
59-
60-
- name: Generate artifact attestation
61-
uses: actions/attest-build-provenance@v2
62-
with:
63-
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
64-
subject-digest: ${{ steps.push.outputs.digest }}
65-
push-to-registry: true

0 commit comments

Comments
 (0)