fix(all): alleviate staticcheck issues #779
This file contains 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: Build and deploy | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
GOOGLE_REGISTRY: "europe-north1-docker.pkg.dev" | |
FEATURE_NAME: "digdirator" | |
on: | |
push: | |
paths-ignore: | |
- "*.md" | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout latest code | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # ratchet:actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # ratchet:actions/setup-go@v5 | |
with: | |
go-version: '1.23' | |
check-latest: true | |
- name: Setup Test | |
run: | | |
make setup-envtest | |
- name: Check for vulnerable dependencies and static code | |
run: | | |
make check | |
- name: Test Go | |
run: | | |
make test | |
build_and_push: | |
needs: test | |
name: Publish to Google and GitHub registries | |
if: github.ref == 'refs/heads/master' | |
permissions: | |
contents: "read" | |
id-token: "write" | |
packages: "write" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # ratchet:actions/checkout@v4 | |
- name: Install cosign | |
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # ratchet:sigstore/cosign-installer@main | |
with: | |
cosign-release: 'v2.2.3' | |
- name: Verify runner image | |
run: cosign verify --certificate-oidc-issuer https://accounts.google.com --certificate-identity [email protected] gcr.io/distroless/static-debian12:nonroot | |
- uses: nais/platform-build-push-sign@main # ratchet:exclude | |
id: build_push_sign | |
with: | |
name: ${{ env.FEATURE_NAME }} | |
dockerfile: Dockerfile | |
google_service_account: gh-${{ env.FEATURE_NAME }} | |
push: true | |
push_ghcr: true | |
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }} | |
- uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # ratchet:azure/setup-helm@v4 | |
with: | |
version: "v3.12.2" | |
- name: Package chart | |
id: package_chart | |
env: | |
CHART_PATH: ./charts | |
run: | | |
base_version="$(yq '.version' < "${{ env.CHART_PATH }}/Chart.yaml")" | |
chart_version="${base_version}-${{ steps.build_push_sign.outputs.version }}" | |
yq eval \ | |
'.version="'"$chart_version"'"' \ | |
"${{ env.CHART_PATH }}/Chart.yaml" --inplace | |
yq eval \ | |
'.image.tag="${{ steps.build_push_sign.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 | |
outputs: | |
chart_name: ${{ steps.package_chart.outputs.name }} | |
chart_version: ${{ steps.package_chart.outputs.version }} | |
chart_archive: ${{ steps.package_chart.outputs.archive }} | |
rollout: | |
runs-on: fasit-deploy | |
if: github.ref == 'refs/heads/master' | |
permissions: | |
id-token: write | |
needs: | |
- build_and_push | |
steps: | |
- uses: nais/fasit-deploy@v2 # ratchet:exclude | |
with: | |
chart: oci://${{ env.GOOGLE_REGISTRY }}/nais-io/nais/feature/${{ needs.build_and_push.outputs.chart_name }} | |
version: ${{ needs.build_and_push.outputs.chart_version }} |