Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
Push to GAR
Browse files Browse the repository at this point in the history
  • Loading branch information
runska committed Aug 9, 2023
1 parent 44e60b6 commit 7b38794
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 43 deletions.
85 changes: 42 additions & 43 deletions .github/workflows/build-deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,94 +1,93 @@
name: Build and deploy
run-name: Build and deploy || ${{ github.event.head_commit.message }}

on: [ push ]

env:
IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}

concurrency:
group: build-deploy-on-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
compile-test-and-build:
name: Build and run tests
docker-build-push:
name: Build, test and push docker image
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
registry-url: https://npm.pkg.github.com/
cache: 'yarn'
node-version: 16
registry-url: https://npm.pkg.github.com
cache: yarn
cache-dependency-path: |
yarn.lock
server/yarn.lock
- name: Install dependencies for server
- name: Install server dependencies
run: cd server && yarn install --frozen-lockfile --prefer-offline
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
- name: Install dependencies
- name: Install client dependencies
run: yarn install --frozen-lockfile --prefer-offline
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
- name: Run tests
run: yarn test
- name: Build application
run: yarn build
env:
CI: false
- name: Login to GitHub Docker Registry
uses: docker/login-action@v2
- name: Push to Google Artifact Registry
uses: nais/docker-build-push@v0
id: docker-push
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push the Docker image
run: |
docker build . -t ${IMAGE}
docker push ${IMAGE}
team: teamia
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
salsa: false
outputs:
image: ${{ steps.docker-push.outputs.image }}

deploy-to-dev-gcp:
name: Deploy to dev-gcp
if: github.ref == 'refs/heads/session-metric-v2'
needs: compile-test-and-build
if: github.ref == 'refs/heads/gar'
needs: docker-build-push
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
VAR: version=${{ env.IMAGE }}
RESOURCE: nais/dev-gcp.yaml
PRINT_PAYLOAD: true
IMAGE: ${{ needs.docker-build-push.outputs.image }}
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
RESOURCE: nais/dev.yaml

deploy-to-dev-gcp-ekstern:
name: Deploy to dev-gcp-ekstern
if: github.ref == 'refs/heads/master'
needs: compile-test-and-build
name: Deploy to dev-gcp (ekstern)
if: github.ref == 'refs/heads/main'
needs: docker-build-push
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
VAR: version=${{ env.IMAGE }}
RESOURCE: nais/dev-gcp-ekstern.yaml
PRINT_PAYLOAD: true
IMAGE: ${{ needs.docker-build-push.outputs.image }}
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}

deploy-to-prod-gcp:
name: Deploy to prod-gcp
if: github.ref == 'refs/heads/master'
needs: compile-test-and-build
if: github.ref == 'refs/heads/main'
needs: docker-build-push
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
VAR: version=${{ env.IMAGE }}
IMAGE: ${{ needs.docker-build-push.outputs.image }}
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
RESOURCE: nais/prod-gcp.yaml
PRINT_PAYLOAD: true
File renamed without changes.
File renamed without changes.

0 comments on commit 7b38794

Please sign in to comment.