build-test-image.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. name: Build and Publish Test Image
  2. on:
  3. merge_group:
  4. types: [checks_requested]
  5. pull_request_target:
  6. branches:
  7. - develop
  8. env:
  9. REGISTRY: ghcr.io
  10. jobs:
  11. check_actor_permissions:
  12. runs-on: ubuntu-latest
  13. outputs:
  14. ismaintainer: ${{ steps.teamAffiliation.outputs.isTeamMember }}
  15. steps:
  16. - name: Check if actor is a maintainer
  17. uses: tspascoal/get-user-teams-membership@v2
  18. id: teamAffiliation
  19. with:
  20. GITHUB_TOKEN: ${{ secrets.ORG_READER_PAT }}
  21. username: ${{ github.actor }}
  22. team: opencost-maintainers
  23. build-and-publish-test-image:
  24. runs-on: ubuntu-latest
  25. needs: check_actor_permissions
  26. if: ${{ (always() && !cancelled()) && ( github.event_name == 'merge_group' || needs.check_actor_permissions.outputs.ismaintainer == 'true') }}
  27. permissions:
  28. contents: read
  29. packages: write
  30. steps:
  31. - name: Checkout Repo
  32. uses: actions/checkout@v4
  33. with:
  34. ref: ${{ github.event.merge_group.head_sha }}
  35. - name: Set SHA
  36. id: sha
  37. run: |
  38. echo "OC_SHORTHASH=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
  39. - name: Set OpenCost Image Tags
  40. id: tags
  41. run: |
  42. echo "IMAGE_TAG=ghcr.io/${{ github.repository_owner }}/opencost:test-${{ steps.sha.outputs.OC_SHORTHASH }}" >> $GITHUB_OUTPUT
  43. - name: Build and publish container
  44. uses: ./.github/actions/build-container
  45. with:
  46. actor: ${{ github.actor }}
  47. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  48. image_tag: ${{ steps.tags.outputs.IMAGE_TAG }}
  49. release_version: test-${{ steps.sha.outputs.OC_SHORTHASH }}