fix: Fix docker login for oauth logins

This commit is contained in:
Gerald Pinder 2024-08-21 16:04:37 -04:00
parent 1177a6d873
commit 020f89d4d1
3 changed files with 159 additions and 43 deletions

View file

@ -313,6 +313,77 @@ jobs:
grep -q 'ARG IMAGE_REGISTRY=ghcr.io/blue-build' Containerfile || exit 1
bluebuild build --retry-push -S sigstore --push -vv recipes/recipe.yml recipes/recipe-39.yml
docker-build-oauth-login:
timeout-minutes: 60
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
needs:
- build
if: needs.build.outputs.push == 'true'
steps:
- name: Google Auth
id: auth
uses: "google-github-actions/auth@v2"
with:
token_format: "access_token"
service_account: ${{ secrets.SERVICE_ACCOUNT }}
project_id: bluebuild-oidc
create_credentials_file: false
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY }}
- name: Maximize build space
uses: ublue-os/remove-unwanted-software@v6
- uses: sigstore/cosign-installer@v3.3.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Docker Auth
id: docker-auth
uses: "docker/login-action@v3"
with:
username: "oauth2accesstoken"
password: "${{ steps.auth.outputs.access_token }}"
registry: us-east1-docker.pkg.dev
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Install bluebuild
run: |
cargo install --path . --debug --all-features
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Run Build
env:
GH_PR_EVENT_NUMBER: ${{ github.event.number }}
COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }}
BB_BUILDKIT_CACHE_GHA: true
run: |
cd integration-tests/test-repo
bluebuild template -vv | tee Containerfile
bluebuild build \
--registry us-east1-docker.pkg.dev \
--registry-namespace bluebuild-oidc/bluebuild \
--retry-push \
--push \
-vv \
recipes/recipe.yml recipes/recipe-39.yml
podman-build:
timeout-minutes: 60
runs-on: ubuntu-latest

View file

@ -311,6 +311,75 @@ jobs:
grep -q 'ARG IMAGE_REGISTRY=ghcr.io/blue-build' Containerfile || exit 1
bluebuild build --retry-push -S sigstore --push -vv recipes/recipe.yml recipes/recipe-39.yml
docker-build-oauth-login:
timeout-minutes: 60
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
needs:
- build
if: github.repository == 'blue-build/cli'
steps:
- name: Google Auth
id: auth
uses: "google-github-actions/auth@v2"
with:
token_format: "access_token"
service_account: ${{ secrets.SERVICE_ACCOUNT }}
project_id: bluebuild-oidc
create_credentials_file: false
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY }}
- name: Maximize build space
uses: ublue-os/remove-unwanted-software@v6
- uses: sigstore/cosign-installer@v3.3.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Docker Auth
id: docker-auth
uses: "docker/login-action@v3"
with:
username: "oauth2accesstoken"
password: "${{ steps.auth.outputs.access_token }}"
registry: us-east1-docker.pkg.dev
- uses: actions/checkout@v4
with:
ref: main
- name: Install bluebuild
run: |
cargo install --path . --debug --all-features
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Run Build
env:
GH_PR_EVENT_NUMBER: ${{ github.event.number }}
COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }}
BB_BUILDKIT_CACHE_GHA: true
run: |
cd integration-tests/test-repo
bluebuild template -vv | tee Containerfile
bluebuild build \
--registry us-east1-docker.pkg.dev \
--registry-namespace bluebuild-oidc/bluebuild \
--retry-push \
--push \
-vv \
recipes/recipe.yml recipes/recipe-39.yml
podman-build:
timeout-minutes: 60
runs-on: ubuntu-latest