Skip to content

Commit

Permalink
Update workflows, add branch deploy option
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-meidell committed Oct 16, 2024
1 parent 8527ec7 commit f5af3c1
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 131 deletions.
28 changes: 11 additions & 17 deletions .github/workflows/build_feature_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,22 @@ on:
- '*/*'
- '!main'
jobs:
tag_build_and_deploy:
name: 'Build, deploy and tag'
runs-on: ubuntu-latest
build:
permissions:
contents: read
packages: write
contents: "read"
id-token: "write"
runs-on: ubuntu-latest
steps:
# PULLER REPO
- name: 'Pull repo'
uses: actions/checkout@v3

# JAVA 17
- name: 'Java 17'
uses: actions/setup-java@v3
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Setup Java'
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
java-version: 21
cache: 'gradle'

# BYGGER DOCKER CONTAINER
- name: 'Bygg og publiser docker image'
- name: 'Build code'
run: |
./gradlew build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41 changes: 41 additions & 0 deletions .github/workflows/deploy_branch_gcp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 'Bygg og deploy branch til dev-gcp'

on:
workflow_dispatch:

jobs:
build_and_push:
permissions:
contents: "read"
id-token: "write"
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Setup Java'
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
cache: 'gradle'
- name: 'Build code'
run: |
./gradlew build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 'Build and push docker image'
uses: nais/docker-build-push@v0
id: docker-push
with:
team: pensjonopptjening
tag: ${{ github.sha }}-${{ github.ref_name }}
image_suffix: ${{ github.ref_name }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} # required, but is defined as an organization variable
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} # required, but is defined as an organization secret
- name: 'Deploy til dev-gcp'
uses: nais/deploy/actions/deploy@v2
env:
RESOURCE: nais/dev-gcp.yml,nais/unleash-apitoken-dev-gcp.yml
CLUSTER: dev-gcp
IMAGE: ${{ steps.docker-push.outputs.image }}
TELEMETRY: ${{ steps.docker-push.outputs.telemetry }}
57 changes: 0 additions & 57 deletions .github/workflows/deploy_dev_gcp.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/deploy_gcp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: 'Bygg og deploy til prod-gcp og dev-gcp'

on:
workflow_dispatch:
push:
branches:
- main
jobs:
build_and_push:
permissions:
contents: "read"
id-token: "write"
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Setup Java'
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
cache: 'gradle'
- name: 'Build code'
run: |
./gradlew build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 'Build and push docker image'
uses: nais/docker-build-push@v0
id: docker-push
with:
team: pensjonopptjening
tag: ${{ github.sha }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} # required, but is defined as an organization variable
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} # required, but is defined as an organization secret
- name: 'Deploy til dev-gcp'
uses: nais/deploy/actions/deploy@v2
env:
RESOURCE: nais/dev-gcp.yml,nais/unleash-apitoken-dev-gcp.yml
CLUSTER: dev-gcp
IMAGE: ${{ steps.docker-push.outputs.image }}
TELEMETRY: ${{ steps.docker-push.outputs.telemetry }}
- name: 'Deploy til prod-gcp'
uses: nais/deploy/actions/deploy@v2
env:
RESOURCE: nais/prod-gcp.yml,nais/unleash-apitoken-prod-gcp.yml
CLUSTER: prod-gcp
IMAGE: ${{ steps.docker-push.outputs.image }}
TELEMETRY: ${{ steps.docker-push.outputs.telemetry }}
57 changes: 0 additions & 57 deletions .github/workflows/deploy_prod_gcp.yml

This file was deleted.

0 comments on commit f5af3c1

Please sign in to comment.