Build and publish Firefly image #9
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and publish Firefly image | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| git_tag: | |
| description: "Git tag to use(e.g. 'release-xxxx.x.x' or a full git tag)" | |
| required: true | |
| type: string | |
| img_tag: | |
| description: "Optional: Docker image tag(e.g. 'xxxx.x.x'); If omitted, `git_tag` will be used." | |
| required: false | |
| type: string | |
| push_image: | |
| description: "Push image to GHCR" | |
| required: false | |
| default: false | |
| type: boolean | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # initial checkout to make local actions available | |
| - name: Checkout Firefly | |
| uses: actions/checkout@v4 | |
| with: | |
| path: firefly | |
| # ------------------------------------------------------------- | |
| # Use local action to resolve git ref and image tag from inputs | |
| # ------------------------------------------------------------- | |
| - name: Resolve tags | |
| id: resolve_tags | |
| uses: ./firefly/.github/actions/resolve-tags | |
| with: | |
| git_tag: ${{ inputs.git_tag }} | |
| img_tag: ${{ inputs.img_tag }} | |
| # ------------------------------------------------------------ | |
| # Checkout firefly (this repo) | |
| # ------------------------------------------------------------ | |
| - name: Checkout Firefly | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ steps.resolve_tags.outputs.ref }} | |
| path: firefly | |
| # ------------------------------------------------------------ | |
| # Checkout Firefly online help | |
| # ------------------------------------------------------------ | |
| - name: Checkout Firefly Help | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: Caltech-IPAC/firefly-help | |
| ref: master | |
| path: firefly-help | |
| # ------------------------------------------------------------ | |
| # Setup Docker multi-platform build | |
| # ------------------------------------------------------------ | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # ------------------------------------------------------------ | |
| # Login to GHCR (only if pushing) | |
| # ------------------------------------------------------------ | |
| - name: Login to GHCR | |
| if: github.event_name == 'release' || inputs.push_image | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # ------------------------------------------------------------ | |
| # Build (and optionally push) multi-platform image | |
| # ------------------------------------------------------------ | |
| - name: Build and push image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: firefly/docker/Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: ${{ github.event_name == 'release' || inputs.push_image }} | |
| # docker buildx does not allow uppercase letters in tags, so we convert to lowercase here | |
| tags: ghcr.io/caltech-ipac/firefly:${{ steps.resolve_tags.outputs.tag }} | |
| build-args: | | |
| env=ops | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| # ------------------------------------------------------------ | |
| # Package and push Helm chart to GHCR | |
| # ------------------------------------------------------------ | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v4 | |
| - name: Publish Helm chart | |
| if: github.event_name == 'release' || inputs.push_image | |
| run: | | |
| if [[ ! -f firefly/helm/Chart.yaml ]]; then | |
| echo "No Helm chart found, skipping." | |
| exit 0 | |
| fi | |
| # align chart appVersion with the image tag | |
| sed -i "s/^appVersion:.*/appVersion: \"${{ steps.resolve_tags.outputs.tag }}\"/" firefly/helm/Chart.yaml | |
| helm package firefly/helm/ | |
| helm push firefly-*.tgz oci://ghcr.io/caltech-ipac |