|
| 1 | +name: Build and push Bundler Docker image |
| 2 | +permissions: |
| 3 | + contents: read |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + tags: |
| 9 | + - "*" |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + build-push-image: |
| 21 | + name: Build and push Bundler Docker image |
| 22 | + runs-on: [matterlabs-ci-runner] |
| 23 | + # Only run docker build/push for the main repository, not forks |
| 24 | + # Allow manual dispatch from any repository |
| 25 | + if: github.repository == 'matter-labs/zksync-sso' |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 28 | + with: |
| 29 | + submodules: recursive |
| 30 | + |
| 31 | + - name: Set git SHA |
| 32 | + id: git_sha |
| 33 | + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT |
| 34 | + |
| 35 | + - name: Set Docker tag |
| 36 | + id: docker_tag |
| 37 | + run: | |
| 38 | + ts=$(date +%s%N | cut -b1-13) |
| 39 | + if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then |
| 40 | + echo "tag=${{ steps.git_sha.outputs.sha_short }}-${ts}" >> $GITHUB_OUTPUT |
| 41 | + elif [[ "${{ github.ref }}" == refs/tags/* ]]; then |
| 42 | + echo "tag=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT |
| 43 | + elif [[ "${{ github.event_name }}" == "pull_request" ]]; then |
| 44 | + echo "tag=none" >> $GITHUB_OUTPUT |
| 45 | + else |
| 46 | + echo "Unsupported event ${GITHUB_EVENT_NAME} or ref ${GITHUB_REF}, only refs/heads/, refs/tags/, pull_request, and workflow_dispatch are supported." |
| 47 | + exit 1 |
| 48 | + fi |
| 49 | +
|
| 50 | + - name: Set up Docker Buildx |
| 51 | + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.0 |
| 52 | + |
| 53 | + - name: Log in to Docker Hub |
| 54 | + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 |
| 55 | + with: |
| 56 | + username: ${{ secrets.DOCKERHUB_USER }} |
| 57 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 58 | + |
| 59 | + - name: Login to GAR |
| 60 | + run: | |
| 61 | + gcloud auth configure-docker us-docker.pkg.dev -q |
| 62 | +
|
| 63 | + - name: Build and push bundler image |
| 64 | + id: docker_build_bundler |
| 65 | + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 |
| 66 | + with: |
| 67 | + context: packages/bundler |
| 68 | + file: packages/bundler/Dockerfile |
| 69 | + push: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) || github.event_name == 'workflow_dispatch' }} |
| 70 | + tags: | |
| 71 | + matterlabs/sso-bundler:${{ steps.docker_tag.outputs.tag }} |
| 72 | + matterlabs/sso-bundler:latest |
| 73 | + us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/sso-bundler:${{ steps.docker_tag.outputs.tag }} |
| 74 | + us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/sso-bundler:latest |
| 75 | +
|
| 76 | + - name: Print image digest to summary |
| 77 | + run: | |
| 78 | + echo "Bundler Image tag: ${{ steps.docker_tag.outputs.tag }}" >> $GITHUB_STEP_SUMMARY |
0 commit comments