|
1 | 1 | name: Docker Image CI/CD |
2 | | - |
3 | | -# Trigger the workflow |
| 2 | + |
4 | 3 | on: |
5 | 4 | push: |
6 | 5 | branches: |
7 | | - - main # Trigger on push to the main branch |
| 6 | + - main # Trigger on push to the main branch |
8 | 7 | # Build container if these files are changed |
9 | 8 | paths: |
10 | 9 | - 'Dockerfile-ppp' |
11 | 10 | - 'ppp/runscript.sh' |
12 | 11 | - 'ppp/cylc-flow-tools.yaml' |
13 | 12 | - '.github/workflows/update_ppp_image.yaml' |
| 13 | + repository_dispatch: |
| 14 | + types: [fre-cli-release] |
14 | 15 |
|
15 | 16 | env: |
16 | 17 | REGISTRY: ghcr.io |
17 | 18 | IMAGE_NAME: "NOAA-GFDL/HPC-ME/ppp" |
18 | 19 |
|
19 | | -# Define the jobs to run |
20 | 20 | jobs: |
21 | 21 | build-and-push: |
22 | 22 | runs-on: ubuntu-latest |
23 | 23 | permissions: |
24 | | - contents: read # Allow checkout |
25 | | - packages: write # Allow pushing to GitHub Packages/GHCR |
| 24 | + contents: read # Allow checkout |
| 25 | + packages: write # Allow pushing to GitHub Packages/GHCR |
26 | 26 |
|
27 | 27 | steps: |
28 | | - # Setup and Checkout |
29 | 28 | - name: Checkout repository |
30 | 29 | uses: actions/checkout@v4 |
31 | | - |
32 | | - # Determine Tags |
33 | | - - name: Extract metadata (tags) for Docker |
34 | | - id: meta |
35 | | - uses: docker/metadata-action@v5 |
36 | 30 | with: |
37 | | - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
38 | | - tags: | |
39 | | - type=sha,prefix=sha-,value=${{ github.sha }},enable=true,priority=1000 |
40 | | - type=raw,value=latest,enable=true |
41 | | - type=raw,value=2025.04,enable=true #Adding fre-cli tag manually for now |
| 31 | + fetch-depth: 0 # Ensure tags are available |
| 32 | + |
| 33 | + - name: Set PPP Tag |
| 34 | + id: set_tag |
| 35 | + run: | |
| 36 | + if [ ! -z "${{ github.event.client_payload.tag }}" ]; then |
| 37 | + TAG="${{ github.event.client_payload.tag }}" |
| 38 | + else |
| 39 | + TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "latest") |
| 40 | + fi |
| 41 | + echo "docker_tag=$TAG" >> $GITHUB_OUTPUT |
42 | 42 |
|
43 | | - # Login to GHCR |
44 | 43 | - name: Log in to the Container registry |
45 | 44 | uses: docker/login-action@v3 |
46 | 45 | with: |
47 | 46 | registry: ${{ env.REGISTRY }} |
48 | 47 | username: ${{ github.actor }} |
49 | 48 | password: ${{ secrets.GITHUB_TOKEN }} |
50 | 49 |
|
51 | | - # Build and Push |
52 | 50 | - name: Build and push Docker image |
53 | 51 | uses: docker/build-push-action@v5 |
54 | 52 | with: |
55 | 53 | context: . # Directory containing the Dockerfile |
56 | 54 | file: ./Dockerfile-ppp |
57 | 55 | push: true |
58 | | - tags: ${{ steps.meta.outputs.tags }} |
59 | | - labels: ${{ steps.meta.outputs.labels }} |
| 56 | + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.set_tag.outputs.docker_tag }} |
0 commit comments