Bump the otel group with 7 updates (#423) #678
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: Container Image | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
GHCR_REGISTRY: ghcr.io | |
GAR_REGISTRY: europe-north1-docker.pkg.dev/nais-io/nais/images | |
ARTIFACT_REGISTRY: europe-north1-docker.pkg.dev | |
ARTIFACT_REPO: nais-io/nais/images | |
SERVICE_ACCOUNT: gh-bifrost@nais-io.iam.gserviceaccount.com | |
jobs: | |
meta: | |
name: Metadata | |
runs-on: ubuntu-latest | |
outputs: | |
"version": ${{ steps.version.outputs.version }} | |
"name": ${{ steps.name.outputs.name }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- id: version | |
run: echo "version=$(date +'%Y%m%d')-$(git rev-parse --short HEAD)" >> ${GITHUB_OUTPUT} | |
- id: name | |
run: echo "name=${{ github.event.repository.name }}" >> ${GITHUB_OUTPUT} | |
lint: | |
name: Lint code | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go environment | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.22" | |
cache: false | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
version: latest | |
args: --timeout=5m | |
build: | |
name: Build and Test code | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Restore cached binaries | |
uses: actions/cache/restore@v4 | |
with: | |
path: ${{ github.workspace }}/bin | |
key: ${{ runner.os }}-bin-${{ hashFiles('Makefile', 'go.mod') }} | |
- name: Set up Go environment | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.22" | |
- name: Install make | |
run: sudo apt-get update && sudo apt-get install make | |
- name: Generate code | |
run: | | |
make generate proto | |
if git diff --quiet HEAD --; then | |
echo "Code generated successfully." | |
else | |
echo "Code has generation issues." | |
echo $(git diff HEAD --) | |
echo "Please run 'make generate proto' and commit the changes." | |
exit 1 | |
fi | |
- name: Generate manifests | |
run: | | |
make manifests | |
if git diff --quiet HEAD --; then | |
echo "Manifests generated successfully." | |
else | |
echo "Manifests have generation issues." | |
echo "Please run 'make manifests' and commit the changes." | |
exit 1 | |
fi | |
- name: Generate helm chart | |
run: | | |
make helm | |
if git diff --quiet HEAD --; then | |
echo "Helm chart generated successfully." | |
else | |
echo "Helm chart has generation issues." | |
echo "Please run 'make helm' and commit the changes." | |
exit 1 | |
fi | |
- name: Vet code | |
run: make vet | |
- name: Test code | |
run: make test | |
- name: Build binary | |
run: make build | |
- name: Cache installed binaries | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/bin | |
key: ${{ runner.os }}-bin-${{ hashFiles('Makefile', 'go.mod') }} | |
docker: | |
name: Build and Push Docker image | |
runs-on: ubuntu-latest-16-cores | |
needs: [meta, lint, build] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.GHCR_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: docker/setup-buildx-action@v3 | |
- uses: docker/metadata-action@v5 | |
id: metadata | |
with: | |
images: | | |
${{ env.GHCR_REGISTRY }}/${{ github.repository }} | |
tags: | | |
type=schedule | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern=v{{version}} | |
type=semver,pattern=v{{major}}.{{minor}} | |
type=semver,pattern=v{{major}} | |
type=sha | |
type=raw,value=${{ needs.meta.outputs.version }} | |
- uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: ${{ github.ref == 'refs/heads/main' }} | |
tags: ${{ steps.metadata.outputs.tags }} | |
labels: ${{ steps.metadata.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
platforms: linux/amd64 |