Skip to content

Commit

Permalink
ci: GAR pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrremann committed Oct 2, 2023
1 parent 88d4306 commit 8a71d0c
Showing 1 changed file with 26 additions and 31 deletions.
57 changes: 26 additions & 31 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,37 @@
name: Build and deploy
name: Build, push, and deploy
on:
push:
branches:
- main

permissions:
packages: write

jobs:
build-push:
name: Build and push image
build:
name: Build and push Docker container
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
steps:
- uses: actions/checkout@v4
- run: echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY}:$(git log -1 --pretty=%ad --date=format:%Y-%m-%d)-$(git log --pretty=format:'%h' -n 1)" >> $GITHUB_ENV
- run: docker build -t $IMAGE .
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
push: true
tags: ${{ env.IMAGE }}
context: .
- uses: actions/checkout@v4
- name: Push docker image to GAR
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: the-g-team
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} # Provided as Organization Secret
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} # Provided as Organization Variable

nais-yaml:
name: Release to nais-yaml
deploy:
name: Deploy to NAIS
needs: build
runs-on: ubuntu-latest
needs: build-push
steps:
- uses: actions/checkout@v4
- run: echo "TAG=$(git log -1 --pretty=%ad --date=format:%Y-%m-%d)-$(git log --pretty=format:'%h' -n 1)" >> $GITHUB_ENV
- name: deploy to prod
uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: nais/nais.yaml,nais/alert.yaml
VAR: TAG=${{ env.TAG }}
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: nais/nais.yaml,nais/alert.yaml
VAR: image=${{ needs.build.outputs.image }}

0 comments on commit 8a71d0c

Please sign in to comment.