Add P-chain test scripts #17
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: container-images | |
| on: | |
| push: | |
| branches: [ "main", "feature/**" ] | |
| tags: [ "v*" ] | |
| jobs: | |
| build-and-push: | |
| name: Build & Push | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| env: | |
| USE_DOCKER_HUB: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: docker/setup-qemu-action@v3 | |
| - uses: docker/setup-buildx-action@v3 | |
| - run: echo "IMAGE_TAG=dev" >> $GITHUB_ENV | |
| if: github.ref_name == 'main' || startsWith(github.ref_name, 'feature/') | |
| - run: echo "IMAGE_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| - name: Login to ghcr.io | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Login to docker.io | |
| if: ${{ env.USE_DOCKER_HUB == 'true' }} | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_UID }} | |
| password: ${{ secrets.DOCKER_HUB_PAT }} | |
| - name: Build standard image | |
| env: | |
| USE_DOCKER_HUB: ${{ env.USE_DOCKER_HUB }} | |
| run: | | |
| TAGS="--tag ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}" | |
| if [ "${USE_DOCKER_HUB}" = "true" ]; then | |
| TAGS="$TAGS --tag ${{ secrets.DOCKER_HUB_REPO }}:${{ env.IMAGE_TAG }}" | |
| fi | |
| docker buildx build \ | |
| --platform linux/amd64,linux/arm64 \ | |
| $TAGS \ | |
| --file ./Dockerfile \ | |
| --output type=image,push=true \ | |
| --iidfile std.digest \ | |
| . | |
| - name: Export standard image digest | |
| run: | | |
| DIG=$(cat std.digest) | |
| echo "IMAGE_DIGEST=$DIG" >> $GITHUB_ENV | |
| - name: Build distroless image | |
| env: | |
| USE_DOCKER_HUB: ${{ env.USE_DOCKER_HUB }} | |
| run: | | |
| TAGS="--tag ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-dless" | |
| if [ "${USE_DOCKER_HUB}" = "true" ]; then | |
| TAGS="$TAGS --tag ${{ secrets.DOCKER_HUB_REPO }}:${{ env.IMAGE_TAG }}-dless" | |
| fi | |
| docker buildx build \ | |
| --platform linux/amd64,linux/arm64 \ | |
| $TAGS \ | |
| --file ./Dockerfile.dless \ | |
| --output type=image,push=true \ | |
| --iidfile dless.digest \ | |
| . | |
| - name: Export distroless image digest | |
| run: | | |
| DIG=$(cat dless.digest) | |
| echo "DLESS_IMAGE_DIGEST=$DIG" >> $GITHUB_ENV | |
| - name: Install Cosign | |
| uses: sigstore/cosign-installer@v3.8.1 | |
| - name: Sign ghcr images | |
| shell: bash | |
| env: | |
| COSIGN_EXPERIMENTAL: 1 | |
| run: | | |
| cosign sign --yes ghcr.io/${{ github.repository }}@${{ env.IMAGE_DIGEST }} | |
| cosign sign --yes ghcr.io/${{ github.repository }}@${{ env.DLESS_IMAGE_DIGEST }} | |
| - name: Sign docker hub images | |
| if: ${{ env.USE_DOCKER_HUB == 'true' }} | |
| shell: bash | |
| env: | |
| COSIGN_EXPERIMENTAL: 1 | |
| run: | | |
| cosign sign --yes ${{ secrets.DOCKER_HUB_REPO }}@${{ env.IMAGE_DIGEST }} | |
| cosign sign --yes ${{ secrets.DOCKER_HUB_REPO }}@${{ env.DLESS_IMAGE_DIGEST }} | |
| - name: Verify ghcr image signatures | |
| shell: bash | |
| env: | |
| COSIGN_EXPERIMENTAL: 1 | |
| run: | | |
| cosign verify \ | |
| --certificate-identity=https://github.com/${{ github.repository }}/.github/workflows/build-container.yml@${{ github.ref }} \ | |
| --certificate-oidc-issuer=https://token.actions.githubusercontent.com \ | |
| "ghcr.io/${{ github.repository }}@${{ env.IMAGE_DIGEST }}" | |
| cosign verify \ | |
| --certificate-identity=https://github.com/${{ github.repository }}/.github/workflows/build-container.yml@${{ github.ref }} \ | |
| --certificate-oidc-issuer=https://token.actions.githubusercontent.com \ | |
| "ghcr.io/${{ github.repository }}@${{ env.DLESS_IMAGE_DIGEST }}" | |
| - name: Verify docker hub image signatures | |
| if: ${{ env.USE_DOCKER_HUB == 'true' }} | |
| shell: bash | |
| env: | |
| COSIGN_EXPERIMENTAL: 1 | |
| run: | | |
| cosign verify \ | |
| --certificate-identity=https://github.com/${{ github.repository }}/.github/workflows/build-container.yml@${{ github.ref }} \ | |
| --certificate-oidc-issuer=https://token.actions.githubusercontent.com \ | |
| "${{ secrets.DOCKER_HUB_REPO }}@${{ env.IMAGE_DIGEST }}" | |
| cosign verify \ | |
| --certificate-identity=https://github.com/${{ github.repository }}/.github/workflows/build-container.yml@${{ github.ref }} \ | |
| --certificate-oidc-issuer=https://token.actions.githubusercontent.com \ | |
| "${{ secrets.DOCKER_HUB_REPO }}@${{ env.DLESS_IMAGE_DIGEST }}" |