|
| 1 | +name: Publish custom tasks image to Github Packages |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches-ignore: |
| 6 | + # Do not run on pushes to main, because this is separately triggred on pushes to main by the |
| 7 | + # isort workflow, and we want to make sure it runs after isort, and not twice |
| 8 | + - main |
| 9 | + workflow_call: |
| 10 | + |
| 11 | +env: |
| 12 | + REGISTRY: ghcr.io |
| 13 | + IMAGE_NAME: open-forest-observatory/argo-workflow-custom-tasks |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-and-push-image: |
| 17 | + if: github.repository == 'open-forest-observatory/ofo-argo' |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + packages: write |
| 23 | + attestations: write |
| 24 | + id-token: write |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout repository |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Log in to the Container registry |
| 31 | + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 |
| 32 | + with: |
| 33 | + registry: ${{ env.REGISTRY }} |
| 34 | + username: ${{ github.actor }} |
| 35 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + |
| 37 | + - name: Extract metadata (tags, labels) for Docker |
| 38 | + id: meta |
| 39 | + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
| 40 | + with: |
| 41 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 42 | + tags: | |
| 43 | + # Tag with branch name on branch pushes |
| 44 | + type=ref,event=branch |
| 45 | + type=ref,event=tag |
| 46 | + type=ref,event=pr |
| 47 | + # Only apply latest tag to main branch |
| 48 | + type=raw,value=latest,enable={{is_default_branch}} |
| 49 | +
|
| 50 | + - name: Build and push Docker image |
| 51 | + id: push |
| 52 | + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 |
| 53 | + with: |
| 54 | + context: ./workflow-custom-tasks |
| 55 | + push: true |
| 56 | + tags: ${{ steps.meta.outputs.tags }} |
| 57 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments