|
| 1 | +name: Build and Push KeyFunder Image to GCR |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [main] |
| 5 | + tags: |
| 6 | + - '**' |
| 7 | + pull_request: |
| 8 | + paths: |
| 9 | + - 'typescript/keyfunder/**' |
| 10 | + - '.github/workflows/keyfunder-docker.yml' |
| 11 | + workflow_dispatch: |
| 12 | + inputs: |
| 13 | + include_arm64: |
| 14 | + description: 'Include arm64 in the build' |
| 15 | + required: false |
| 16 | + default: 'false' |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: build-push-keyfunder-${{ github.ref }} |
| 20 | + cancel-in-progress: true |
| 21 | + |
| 22 | +jobs: |
| 23 | + check-env: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + outputs: |
| 26 | + gcloud-service-key: ${{ steps.gcloud-service-key.outputs.defined }} |
| 27 | + steps: |
| 28 | + - id: gcloud-service-key |
| 29 | + env: |
| 30 | + GCLOUD_SERVICE_KEY: ${{ secrets.GCLOUD_SERVICE_KEY }} |
| 31 | + if: "${{ env.GCLOUD_SERVICE_KEY != '' }}" |
| 32 | + run: echo "defined=true" >> $GITHUB_OUTPUT |
| 33 | + |
| 34 | + build-and-push-to-gcr: |
| 35 | + runs-on: ubuntu-latest |
| 36 | + permissions: |
| 37 | + contents: read |
| 38 | + id-token: write |
| 39 | + pull-requests: write |
| 40 | + |
| 41 | + needs: [check-env] |
| 42 | + if: needs.check-env.outputs.gcloud-service-key == 'true' |
| 43 | + |
| 44 | + steps: |
| 45 | + - name: Generate GitHub App Token |
| 46 | + id: generate-token |
| 47 | + uses: actions/create-github-app-token@v2 |
| 48 | + with: |
| 49 | + app-id: ${{ secrets.HYPER_GONK_APP_ID }} |
| 50 | + private-key: ${{ secrets.HYPER_GONK_PRIVATE_KEY }} |
| 51 | + |
| 52 | + - uses: actions/checkout@v5 |
| 53 | + with: |
| 54 | + ref: ${{ github.event.pull_request.head.sha || github.sha }} |
| 55 | + submodules: recursive |
| 56 | + fetch-depth: 0 |
| 57 | + |
| 58 | + - name: Generate tag data |
| 59 | + id: taggen |
| 60 | + run: | |
| 61 | + echo "TAG_DATE=$(date +'%Y%m%d-%H%M%S')" >> $GITHUB_OUTPUT |
| 62 | + echo "TAG_SHA=$(echo '${{ github.event.pull_request.head.sha || github.sha }}' | cut -b 1-7)" >> $GITHUB_OUTPUT |
| 63 | +
|
| 64 | + - name: Docker meta |
| 65 | + id: meta |
| 66 | + uses: docker/metadata-action@v5 |
| 67 | + with: |
| 68 | + images: | |
| 69 | + gcr.io/abacus-labs-dev/hyperlane-keyfunder |
| 70 | + tags: | |
| 71 | + type=ref,event=branch |
| 72 | + type=ref,event=pr |
| 73 | + type=raw,value=${{ steps.taggen.outputs.TAG_SHA }}-${{ steps.taggen.outputs.TAG_DATE }} |
| 74 | +
|
| 75 | + - name: Set up Depot CLI |
| 76 | + uses: depot/setup-action@v1 |
| 77 | + |
| 78 | + - name: Login to GCR |
| 79 | + uses: docker/login-action@v3 |
| 80 | + with: |
| 81 | + registry: gcr.io |
| 82 | + username: _json_key |
| 83 | + password: ${{ secrets.GCLOUD_SERVICE_KEY }} |
| 84 | + |
| 85 | + - name: Determine platforms |
| 86 | + id: determine-platforms |
| 87 | + run: | |
| 88 | + if [ "${{ github.event.inputs.include_arm64 }}" == "true" ]; then |
| 89 | + echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT |
| 90 | + else |
| 91 | + echo "platforms=linux/amd64" >> $GITHUB_OUTPUT |
| 92 | + fi |
| 93 | +
|
| 94 | + - name: Get Foundry version |
| 95 | + id: foundry-version |
| 96 | + run: | |
| 97 | + FOUNDRY_VERSION=$(cat solidity/.foundryrc) |
| 98 | + echo "FOUNDRY_VERSION=$FOUNDRY_VERSION" >> $GITHUB_OUTPUT |
| 99 | +
|
| 100 | + - name: Build and push |
| 101 | + id: build |
| 102 | + uses: depot/build-push-action@v1 |
| 103 | + with: |
| 104 | + project: 3cpjhx94qv |
| 105 | + context: ./ |
| 106 | + file: ./typescript/keyfunder/Dockerfile |
| 107 | + push: true |
| 108 | + tags: ${{ steps.meta.outputs.tags }} |
| 109 | + labels: ${{ steps.meta.outputs.labels }} |
| 110 | + platforms: ${{ steps.determine-platforms.outputs.platforms }} |
| 111 | + build-args: | |
| 112 | + FOUNDRY_VERSION=${{ steps.foundry-version.outputs.FOUNDRY_VERSION }} |
| 113 | + SERVICE_VERSION=${{ steps.taggen.outputs.TAG_SHA }}-${{ steps.taggen.outputs.TAG_DATE }} |
| 114 | +
|
| 115 | + - name: Comment image tags on PR |
| 116 | + if: github.event_name == 'pull_request' |
| 117 | + uses: ./.github/actions/docker-image-comment |
| 118 | + with: |
| 119 | + comment_tag: keyfunder-docker-image |
| 120 | + image_name: KeyFunder Docker Image |
| 121 | + emoji: 🔑 |
| 122 | + image_tags: ${{ steps.meta.outputs.tags }} |
| 123 | + pr_number: ${{ github.event.pull_request.number }} |
| 124 | + github_token: ${{ steps.generate-token.outputs.token }} |
| 125 | + job_status: ${{ job.status }} |
0 commit comments