| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- name: Build and Publish Develop
- on:
- workflow_run:
- workflows: [Build/Test]
- types: [completed]
- branches: [develop]
- concurrency:
- group: build-opencost-develop
- cancel-in-progress: false
- permissions: {}
- env:
- # Use docker.io for Docker Hub if empty
- REGISTRY: ghcr.io
- jobs:
- build-and-publish-opencost:
- runs-on: ubuntu-latest
- if: ${{ github.event.workflow_run.conclusion == 'success' }}
- permissions:
- contents: read
- packages: write
- steps:
- - name: Checkout Repo
- uses: actions/checkout@v4
- - name: Set SHA
- id: sha
- run: |
- echo "OC_SHORTHASH=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- - name: Set OpenCost Image Tags
- id: tags
- env:
- REPO: ${{ github.repository_owner }}
- SHORTHASH: ${{ steps.sha.outputs.OC_SHORTHASH }}
- run: |
- echo "IMAGE_TAG=ghcr.io/$REPO/opencost:develop-$SHORTHASH" >> $GITHUB_OUTPUT
- - name: Build and publish container
- uses: ./.github/actions/build-container
- with:
- actor: ${{ github.actor }}
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- image_tag: ${{ steps.tags.outputs.IMAGE_TAG }}
- release_version: develop-${{ steps.sha.outputs.OC_SHORTHASH }}
-
- - name: Install crane
- uses: imjasonh/setup-crane@v0.4
- - name: Tag and push latest image
- env:
- IMAGE_TAG: ${{ steps.tags.outputs.IMAGE_TAG }}
- run: |
- # Extract the repository part (everything before the last colon)
- REPO=$(echo "$IMAGE_TAG" | sed 's/:.*$//')
- # Create the new tag
- NEW_TAG="${REPO}:develop-latest"
- echo "Copying $IMAGE_TAG to ${NEW_TAG}"
- crane copy "$IMAGE_TAG" "${NEW_TAG}"
|