Merge pull request #225 from oasisprotocol/dependabot/uv/fastapi-0.141.1 #25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ci-docker | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - 'privana/v[0-9]+.[0-9]+.[0-9]+' | |
| - 'privana/v[0-9]+.[0-9]+.[0-9]+-testnet' | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| attestations: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| flavor: | | |
| latest=false | |
| tags: | | |
| type=sha,prefix=,enable=${{ !startsWith(github.ref, 'refs/tags/') }} | |
| type=match,pattern=^privana/(v\d+\.\d+\.\d+(-testnet)?)$,group=1 | |
| type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/privana/v') && !contains(github.ref, '-testnet') }} | |
| type=raw,value=testnet,enable=${{ startsWith(github.ref, 'refs/tags/privana/v') && contains(github.ref, '-testnet') }} | |
| - name: Install Solidity dependencies | |
| run: cd solidity && bun install | |
| - name: Cache Hardhat compiler | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/hardhat-nodejs | |
| key: hardhat-${{ hashFiles('solidity/hardhat.config.ts') }} | |
| - name: Compile Solidity contracts | |
| run: make solidity-build | |
| - name: Build and push | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| annotations: | | |
| index:org.opencontainers.image.description=Privana python backend service. | |
| build-args: | | |
| BUILD_COMMIT=${{ github.sha }} | |
| ENV_FILE=${{ (startsWith(github.ref, 'refs/tags/privana/v') && !contains(github.ref, '-testnet')) && '.env.mainnet' || '.env.testnet' }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| platforms: linux/amd64 | |
| sbom: true | |
| - name: Attest build provenance | |
| uses: actions/attest-build-provenance@v2 | |
| with: | |
| subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| subject-digest: ${{ steps.build.outputs.digest }} | |
| push-to-registry: true | |
| - name: Install ORAS | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: oras-project/setup-oras@v1 | |
| - name: Tag attestation with image tag aliases | |
| if: startsWith(github.ref, 'refs/tags/') | |
| env: | |
| TAGS: ${{ steps.meta.outputs.tags }} | |
| DIGEST: ${{ steps.build.outputs.digest }} | |
| run: | | |
| att_ref="${REGISTRY}/${IMAGE_NAME}:sha256-${DIGEST#sha256:}" | |
| for tag in $TAGS; do | |
| oras tag "$att_ref" "${tag##*:}-att" | |
| done | |
| - name: Prune old images | |
| uses: vlaurin/action-ghcr-prune@v0.6.0 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| organization: oasisprotocol | |
| container: privana | |
| keep-younger-than: 60 | |
| keep-last: 5 | |
| prune-untagged: true |