|
| 1 | +name: "⚒️ Publish Worker RE2" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + image_tag: |
| 7 | + description: The image tag to publish |
| 8 | + type: string |
| 9 | + required: false |
| 10 | + default: "" |
| 11 | + push: |
| 12 | + tags: |
| 13 | + - "re2-test-*" |
| 14 | + - "re2-prod-*" |
| 15 | + |
| 16 | +permissions: |
| 17 | + packages: write |
| 18 | + contents: read |
| 19 | + |
| 20 | +jobs: |
| 21 | + check-branch: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: Fail if re2-prod-* is pushed from a non-main branch |
| 25 | + if: startsWith(github.ref_name, 're2-prod-') && github.base_ref != 'main' |
| 26 | + run: | |
| 27 | + echo "🚫 re2-prod-* tags can only be pushed from the main branch." |
| 28 | + exit 1 |
| 29 | + build: |
| 30 | + strategy: |
| 31 | + matrix: |
| 32 | + package: [supervisor] |
| 33 | + runs-on: ubuntu-latest |
| 34 | + env: |
| 35 | + DOCKER_BUILDKIT: "1" |
| 36 | + steps: |
| 37 | + - name: ⬇️ Checkout git repo |
| 38 | + uses: actions/checkout@v4 |
| 39 | + |
| 40 | + - name: 📦 Get image repo |
| 41 | + id: get_repository |
| 42 | + run: | |
| 43 | + if [[ "${{ matrix.package }}" == *-provider ]]; then |
| 44 | + provider_type=$(echo "${{ matrix.package }}" | cut -d- -f1) |
| 45 | + repo=provider/${provider_type} |
| 46 | + else |
| 47 | + repo="${{ matrix.package }}" |
| 48 | + fi |
| 49 | + echo "repo=${repo}" >> "$GITHUB_OUTPUT" |
| 50 | +
|
| 51 | + - id: get_tag |
| 52 | + uses: ./.github/actions/get-image-tag |
| 53 | + with: |
| 54 | + tag: ${{ inputs.image_tag }} |
| 55 | + |
| 56 | + - name: 🐋 Set up Docker Buildx |
| 57 | + uses: docker/setup-buildx-action@v3 |
| 58 | + |
| 59 | + # ..to avoid rate limits when pulling images |
| 60 | + - name: 🐳 Login to DockerHub |
| 61 | + uses: docker/login-action@v3 |
| 62 | + with: |
| 63 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 64 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 65 | + |
| 66 | + - name: 🚢 Build Container Image |
| 67 | + run: | |
| 68 | + docker build -t infra_image -f ./apps/${{ matrix.package }}/Containerfile . |
| 69 | +
|
| 70 | + # ..to push image |
| 71 | + - name: 🐙 Login to GitHub Container Registry |
| 72 | + uses: docker/login-action@v3 |
| 73 | + with: |
| 74 | + registry: ghcr.io |
| 75 | + username: ${{ github.repository_owner }} |
| 76 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + |
| 78 | + - name: 🐙 Push to GitHub Container Registry |
| 79 | + run: | |
| 80 | + docker tag infra_image "$REGISTRY/$REPOSITORY:$IMAGE_TAG" |
| 81 | + docker push "$REGISTRY/$REPOSITORY:$IMAGE_TAG" |
| 82 | + env: |
| 83 | + REGISTRY: ghcr.io/triggerdotdev |
| 84 | + REPOSITORY: ${{ steps.get_repository.outputs.repo }} |
| 85 | + IMAGE_TAG: ${{ steps.get_tag.outputs.tag }} |
| 86 | + |
| 87 | + - name: 🐙 Push 'v3' tag to GitHub Container Registry |
| 88 | + if: steps.get_tag.outputs.is_semver == 'true' |
| 89 | + run: | |
| 90 | + docker tag infra_image "$REGISTRY/$REPOSITORY:v3" |
| 91 | + docker push "$REGISTRY/$REPOSITORY:v3" |
| 92 | + env: |
| 93 | + REGISTRY: ghcr.io/triggerdotdev |
| 94 | + REPOSITORY: ${{ steps.get_repository.outputs.repo }} |
0 commit comments