|
| 1 | +# Builds and pushes the proxy docker image to the AWS Marketplace ECR |
| 2 | +# |
| 3 | +# here: https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners |
| 4 | +# |
| 5 | +# |
| 6 | +# ECR is a private registry that is not controlled by us |
| 7 | +# Most of the existing Docker actions are not compatible with ECR, so some of this is quite manual |
| 8 | +# |
| 9 | +# Builds for different images are handled using tags, because I could not get other things workings. |
| 10 | +# |
| 11 | +# The tag formats are: |
| 12 | +# - proxy-{os}-{arch}-{release-tag} |
| 13 | +# - proxy-{os}-{arch}-build-{timestamp} |
| 14 | +# |
| 15 | +# ECR is immutable - so test builds need a timestamp or they fail with a conflicts |
| 16 | + |
| 17 | +name: "Proxy — Build & Push Proxy Docker Image for AWS Marketplace" |
| 18 | + |
| 19 | +on: |
| 20 | + release: |
| 21 | + types: |
| 22 | + - published |
| 23 | + pull_request: |
| 24 | + branches: |
| 25 | + - main |
| 26 | + paths: |
| 27 | + - .github/workflows/release-aws-marketplace.yml |
| 28 | + |
| 29 | + workflow_dispatch: |
| 30 | + |
| 31 | + |
| 32 | +env: |
| 33 | + REGISTRY_IMAGE: cipherstash/cipherstash |
| 34 | + AWS_REGION: us-east-1 |
| 35 | + |
| 36 | +jobs: |
| 37 | + build: |
| 38 | + name: 🏗️ Build binaries + Docker images |
| 39 | + permissions: |
| 40 | + contents: read |
| 41 | + packages: write |
| 42 | + id-token: write # This is required for requesting the JWT |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + build: |
| 47 | + - { os: linux-arm64-public, arch: linux/arm64, tag: linux-arm64, cache-provider: github } |
| 48 | + runs-on: ${{matrix.build.os}} |
| 49 | + steps: |
| 50 | + |
| 51 | + - name: install-aws-cli |
| 52 | + uses: unfor19/install-aws-cli-action@v1 |
| 53 | + if: ${{ matrix.build.arch == 'linux/arm64' }} |
| 54 | + with: |
| 55 | + version: 2 # default |
| 56 | + verbose: false # default |
| 57 | + arch: arm64 # allowed values: amd64, arm64 |
| 58 | + |
| 59 | + - name: Configure AWS credentials |
| 60 | + uses: aws-actions/configure-aws-credentials@v4 |
| 61 | + with: |
| 62 | + role-to-assume: ${{ vars.AWS_MARKETPLACE_IAM_ROLE }} |
| 63 | + aws-region: us-east-1 |
| 64 | + |
| 65 | + - name: Log in to AWS Marketplace ECR |
| 66 | + id: ecr-login |
| 67 | + uses: aws-actions/amazon-ecr-login@v2 |
| 68 | + with: |
| 69 | + registries: ${{ vars.AWS_MARKETPLACE_ECR_ID }} |
| 70 | + |
| 71 | + - uses: actions/checkout@v4 |
| 72 | + |
| 73 | + - name: Setup Rust cache |
| 74 | + uses: Swatinem/rust-cache@v2 |
| 75 | + with: |
| 76 | + cache-provider: ${{matrix.build.cache-provider}} |
| 77 | + cache-all-crates: true |
| 78 | + |
| 79 | + - uses: jdx/mise-action@v2 |
| 80 | + with: |
| 81 | + version: 2025.1.6 # [default: latest] mise version to install |
| 82 | + install: true # [default: true] run `mise install` |
| 83 | + cache: true # [default: true] cache mise using GitHub's cache |
| 84 | + |
| 85 | + - run: | |
| 86 | + mise run build --platform ${{matrix.build.arch}} |
| 87 | +
|
| 88 | + - uses: actions/upload-artifact@v4 |
| 89 | + with: |
| 90 | + name: cipherstash-proxy-${{matrix.build.tag}} |
| 91 | + path: cipherstash-proxy |
| 92 | + |
| 93 | + - if: github.event_name != 'pull_request' |
| 94 | + name: Release to AWS |
| 95 | + env: |
| 96 | + AWS_MARKETPLACE_ECR_REPOSITORY: ${{ vars.AWS_MARKETPLACE_ECR_REPOSITORY }} |
| 97 | + BUILD_TAG: ${{ matrix.build.tag }} |
| 98 | + RELEASE_TAG: ${{ github.event.release.tag_name }} |
| 99 | + run: | |
| 100 | + mise run release:aws-marketplace |
| 101 | +
|
| 102 | +
|
0 commit comments