Skip to content

Merge pull request #21 from NOAA-GFDL/RepoDispatch #7

Merge pull request #21 from NOAA-GFDL/RepoDispatch

Merge pull request #21 from NOAA-GFDL/RepoDispatch #7

name: Docker Image CI/CD
on:
push:
branches:
- main # Trigger on push to the main branch
# Build container if these files are changed
paths:
- 'Dockerfile-ppp'
- 'ppp/runscript.sh'
- 'ppp/cylc-flow-tools.yaml'
- '.github/workflows/update_ppp_image.yaml'
repository_dispatch:
types: [fre-cli-release]
env:
REGISTRY: ghcr.io
IMAGE_NAME: "NOAA-GFDL/HPC-ME/ppp"
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read # Allow checkout
packages: write # Allow pushing to GitHub Packages/GHCR
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure tags are available
- name: Set PPP Tag
id: set_tag
run: |
if [ ! -z "${{ github.event.client_payload.tag }}" ]; then
TAG="${{ github.event.client_payload.tag }}"
else
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "latest")
fi
echo "docker_tag=$TAG" >> $GITHUB_OUTPUT
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: . # Directory containing the Dockerfile
file: ./Dockerfile-ppp
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.set_tag.outputs.docker_tag }}