mirror of
https://github.com/nais/wonderwall.git
synced 2026-02-14 17:49:54 +00:00
128 lines
4.7 KiB
YAML
128 lines
4.7 KiB
YAML
name: Build wonderwall
|
|
on: [push]
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
env:
|
|
GOOGLE_REGISTRY: europe-north1-docker.pkg.dev
|
|
GITHUB_REGISTRY: ghcr.io
|
|
permissions:
|
|
contents: read
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout latest code
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6
|
|
- name: Set up Go
|
|
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # ratchet:actions/setup-go@v6
|
|
with:
|
|
go-version-file: 'go.mod'
|
|
- name: Test Go
|
|
run: |
|
|
make test
|
|
make check
|
|
build:
|
|
needs: test
|
|
name: Publish to Google and GitHub registries
|
|
if: github.ref == 'refs/heads/master'
|
|
permissions:
|
|
id-token: "write"
|
|
packages: "write"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6
|
|
- name: Install cosign
|
|
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # ratchet:sigstore/cosign-installer@v4.0.0
|
|
with:
|
|
cosign-release: 'v3.0.2'
|
|
- name: Verify runner image
|
|
run: cosign verify --certificate-oidc-issuer https://accounts.google.com --certificate-identity keyless@distroless.iam.gserviceaccount.com gcr.io/distroless/static-debian12:nonroot
|
|
- uses: nais/platform-build-push-sign@main # ratchet:exclude
|
|
id: build_push_sign
|
|
with:
|
|
name: wonderwall
|
|
dockerfile: Dockerfile
|
|
google_service_account: gh-wonderwall
|
|
multi-platform: true
|
|
push: true
|
|
push_ghcr: true
|
|
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}
|
|
outputs:
|
|
version: ${{ steps.build_push_sign.outputs.version }}
|
|
charts:
|
|
needs: build
|
|
name: Build and push chart
|
|
if: github.ref == 'refs/heads/master'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
id-token: write
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
chart: ["wonderwall", "wonderwall-forward-auth"]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # ratchet:actions/checkout@v6
|
|
- id: "auth"
|
|
name: "Authenticate to Google Cloud"
|
|
uses: "google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093" # ratchet:google-github-actions/auth@v3
|
|
with:
|
|
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}
|
|
service_account: "gh-wonderwall@nais-io.iam.gserviceaccount.com"
|
|
token_format: "access_token"
|
|
- name: "Login to registry"
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # ratchet:docker/login-action@v3
|
|
with:
|
|
registry: "${{ env.GOOGLE_REGISTRY }}/nais-io/nais/feature"
|
|
username: "oauth2accesstoken"
|
|
password: "${{ steps.auth.outputs.access_token }}"
|
|
- uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # ratchet:azure/setup-helm@v4
|
|
name: 'Setup Helm'
|
|
with:
|
|
version: '3.13.2'
|
|
- name: Package chart
|
|
id: package_chart
|
|
env:
|
|
CHART_PATH: ./charts/${{ matrix.chart }}
|
|
run: |
|
|
base_version="1.0.0"
|
|
chart_version="${base_version}-${{ needs.build.outputs.version }}"
|
|
|
|
yq eval \
|
|
'.version="'"$chart_version"'"' \
|
|
"${{ env.CHART_PATH }}/Chart.yaml" --inplace
|
|
yq eval \
|
|
'.image.tag="${{ needs.build.outputs.version }}"' \
|
|
"${{ env.CHART_PATH }}/values.yaml" --inplace
|
|
|
|
helm dependency update "${{ env.CHART_PATH }}"
|
|
helm package "${{ env.CHART_PATH }}" --destination .
|
|
|
|
name=$(yq '.name' < "${{ env.CHART_PATH }}/Chart.yaml")
|
|
echo "name=$name" >> $GITHUB_OUTPUT
|
|
echo "version=$chart_version" >> $GITHUB_OUTPUT
|
|
echo "archive=$name-$chart_version.tgz" >> $GITHUB_OUTPUT
|
|
- name: Push Chart
|
|
run: |-
|
|
chart="${{ steps.package_chart.outputs.archive }}"
|
|
echo "Pushing: $chart"
|
|
helm push "$chart" oci://${{ env.GOOGLE_REGISTRY }}/nais-io/nais/feature
|
|
rollout:
|
|
name: Rollout
|
|
if: github.actor != 'dependabot[bot]' && github.ref == 'refs/heads/master'
|
|
needs: [build, charts]
|
|
runs-on: fasit-deploy
|
|
permissions:
|
|
id-token: write
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
chart: ["wonderwall", "wonderwall-forward-auth"]
|
|
steps:
|
|
- uses: nais/fasit-deploy@v2 # ratchet:exclude
|
|
with:
|
|
chart: oci://${{ env.GOOGLE_REGISTRY }}/nais-io/nais/feature/${{ matrix.chart }}
|
|
version: "1.0.0-${{ needs.build.outputs.version }}"
|