build-test-image.yml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. debug-actor-permissions:
  24. runs-on: ubuntu-latest
  25. needs: check_actor_permissions
  26. if: ${{ always() }}
  27. steps:
  28. - name: Debug actor permissions
  29. run: |
  30. echo "Actor: ${{ github.actor }}"
  31. echo "Is maintainer: ${{ needs.check_actor_permissions.outputs.ismaintainer }}"
  32. build-and-publish-test-image:
  33. runs-on: ubuntu-latest
  34. needs: check_actor_permissions
  35. if: ${{ (always() && !cancelled()) && ( github.event_name == 'merge_group' || needs.check_actor_permissions.outputs.ismaintainer == 'true') }}
  36. permissions:
  37. contents: read
  38. packages: write
  39. steps:
  40. - name: Checkout Repo
  41. uses: actions/checkout@v4
  42. with:
  43. ref: ${{ github.event.merge_group.head_sha }}
  44. - name: Set SHA
  45. id: sha
  46. run: |
  47. echo "OC_SHORTHASH=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
  48. - name: Set OpenCost Image Tags
  49. id: tags
  50. run: |
  51. echo "IMAGE_TAG=ghcr.io/${{ github.repository_owner }}/opencost:test-${{ steps.sha.outputs.OC_SHORTHASH }}" >> $GITHUB_OUTPUT
  52. - name: Build and publish container
  53. uses: ./.github/actions/build-container
  54. with:
  55. actor: ${{ github.actor }}
  56. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  57. image_tag: ${{ steps.tags.outputs.IMAGE_TAG }}
  58. release_version: test-${{ steps.sha.outputs.OC_SHORTHASH }}