Skip to content

Build and Publish AnvilOps Docker image #15

Build and Publish AnvilOps Docker image

Build and Publish AnvilOps Docker image #15

name: Build and Publish AnvilOps Docker image
on:
push:
branches: [main]
paths-ignore:
- "infra/**"
- "charts/**"
- "builders/**"
- "docs/**" # The docs are hosted on AnvilOps!
workflow_dispatch:
jobs:
push_to_registry:
name: Push AnvilOps Docker image to Harbor
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v6
- name: Log in to container registry
run: docker login -u '${{ secrets.DOCKER_USERNAME }}' -p '${{ secrets.DOCKER_PASSWORD }}' registry.anvil.rcac.purdue.edu
- name: Build and push AnvilOps Docker image
run: docker build --push -t registry.anvil.rcac.purdue.edu/anvilops/anvilops:${{ github.ref_name }}-${{ github.run_number }}-${{ github.sha }}${{ github.event_name == 'push' && ' -t registry.anvil.rcac.purdue.edu/anvilops/anvilops:latest' || '' }} --cache-from=type=registry,ref=registry.anvil.rcac.purdue.edu/anvilops/anvilops:latest --cache-to=type=inline .
- name: Log into container registry (Geddes)
run: docker login -u '${{ secrets.DOCKER_USERNAME }}' -p '${{ secrets.DOCKER_PASSWORD_GEDDES }}' geddes-registry.rcac.purdue.edu
- name: Build and push AnvilOps Docker image (Geddes)
run: docker build --build-arg GEDDES=true --push -t geddes-registry.rcac.purdue.edu/anvilops/anvilops:${{ github.ref_name }}-${{ github.run_number }}-${{ github.sha }}${{ github.event_name == 'push' && ' -t geddes-registry.rcac.purdue.edu/anvilops/anvilops:latest' || '' }} --cache-from=type=registry,ref=geddes-registry.rcac.purdue.edu/anvilops/anvilops:latest --cache-to=type=inline .
- name: Log out of container registry
if: always()
run: docker logout registry.anvil.rcac.purdue.edu
- name: Log out of container registry (Geddes)
if: always()
run: docker logout geddes-registry.anvil.rcac.purdue.edu
- name: Install yq
run: |
wget https://github.com/mikefarah/yq/releases/download/v4.47.2/yq_linux_amd64 -O ./yq &&\
chmod +x yq
- name: Update values.yaml files
run: |
./yq -i '.anvilops.image = "registry.anvil.rcac.purdue.edu/anvilops/anvilops:${{ github.ref_name }}-${{ github.run_number }}-${{ github.sha }}"' infra/anvil/values.yaml
./yq -i '.anvilops.image = "geddes-registry.rcac.purdue.edu/anvilops/anvilops:${{ github.ref_name }}-${{ github.run_number }}-${{ github.sha }}"' infra/geddes/values.yaml
cat infra/anvil/values.yaml
- name: Commit changes
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config pull.rebase true
git add infra/anvil/values.yaml infra/geddes/values.yaml
git commit -m "Update image to ${{ github.ref_name }}-${{ github.run_number }}-${{ github.sha }}" || echo "No changes to commit"
git push || git pull && git push