Skip to content

Commit

Permalink
Update deploy workflows (#187)
Browse files Browse the repository at this point in the history
* Update deploy workflow to also trigger on workflow dispatch and to use octo sts

* update git username on workflows

* Trying to resolve the issue with gralde dependency graph

* Update some namings
  • Loading branch information
larsore authored Aug 29, 2024
1 parent b98b78b commit de622aa
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 20 deletions.
59 changes: 48 additions & 11 deletions .github/workflows/build-deploy-backend.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
name: Build and deploy backend to SKIP
on:
workflow_dispatch:
inputs:
commit_sha:
description: 'Commit hash to deploy'
default: ''
type: string
dev:
description: 'Deploy to dev'
required: true
type: boolean
prod:
description: 'Deploy to prod'
required: true
type: boolean
pull_request:
branches:
- main
Expand Down Expand Up @@ -38,7 +51,20 @@ jobs:
image_url: ${{ steps.setOutput.outputs.image_url }}

steps:
- uses: actions/checkout@v4
- name: Checkout code
if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.commit_sha == '') }}
uses: actions/checkout@v4

- name: Checkout code
if: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_sha == '' }}
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Checkout specific commit
if: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_sha == '' }}
run: git checkout ${{ github.event.inputs.commit_sha }}

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
Expand All @@ -48,8 +74,10 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

# - name: Generate and submit dependency graph
# uses: gradle/actions/dependency-submission@v3
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@v3
with:
build-root-directory: backend

- name: Execute Gradle build
working-directory: backend
Expand Down Expand Up @@ -97,7 +125,7 @@ jobs:
echo "image_url=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-docker.outputs.digest }}" >> $GITHUB_OUTPUT
pharos:
name: Run Pharos on docker image
name: Run Pharos
needs: build
permissions:
actions: read
Expand All @@ -111,22 +139,31 @@ jobs:
with:
image_url: ${{ needs.build.outputs.image_url }}

deploy:
name: Deploy to SKIP
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
deploy-dev:
name: Deploy to dev
if: ${{ github.ref == 'refs/heads/main' && (github.event_name != 'workflow_dispatch' || (github.event_name == 'workflow_dispatch' && inputs.dev == 'true')) }}
needs: build
runs-on: ubuntu-latest
environment:
name: dev
permissions:
id-token: write
steps:
- name: Checkout apps-repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: octo-sts/action@6177b4481c00308b3839969c3eca88c96a91775f # v1.0.0
id: octo-sts
with:
scope: kartverket/skvis-apps
identity: regelrett-backend
- name: Checkout skvis-apps
uses: actions/checkout@v4
with:
repository: kartverket/skvis-apps
ref: main
token: ${{ secrets.ARGO_PAT }}
token: ${{ steps.octo-sts.outputs.token }}
- name: Update version
run: |
echo "\"${{ needs.build.outputs.image_url }}\"" > "env/atgcp1-dev/regelrett-main/${{ env.ARGO_VERSION_FILE }}"
git config --global user.email "[email protected]"
git config --global user.name "Regelrett CI"
git commit -am "Update Regelrett frontend ${{ env.ARGO_VERSION_FILE }}"
git commit -am "Update ${{ env.ARGO_VERSION_FILE }}"
git push
52 changes: 43 additions & 9 deletions .github/workflows/build-deploy-frontend.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
name: Build and deploy frontend to SKIP
on:
workflow_dispatch:
inputs:
commit_sha:
description: 'Commit hash to deploy'
default: ''
type: string
dev:
description: 'Deploy to dev'
required: true
type: boolean
prod:
description: 'Deploy to prod'
required: true
type: boolean
pull_request:
branches:
- main
Expand Down Expand Up @@ -34,7 +47,19 @@ jobs:
image_url: ${{ steps.setOutput.outputs.image_url }}

steps:
- uses: actions/checkout@v4
- name: Checkout code
if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.commit_sha == '') }}
uses: actions/checkout@v4

- name: Checkout code
if: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_sha == '' }}
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Checkout specific commit
if: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_sha == '' }}
run: git checkout ${{ github.event.inputs.commit_sha }}

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
Expand Down Expand Up @@ -92,7 +117,7 @@ jobs:
echo "image_url=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-docker.outputs.digest }}" >> $GITHUB_OUTPUT
pharos:
name: Run Pharos with Required Permissions
name: Run Pharos
needs: build
permissions:
actions: read
Expand All @@ -106,22 +131,31 @@ jobs:
with:
image_url: ${{ needs.build.outputs.image_url }}

deploy:
name: Deploy to SKIP
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
deploy-dev:
name: Deploy to dev
if: ${{ github.ref == 'refs/heads/main' && (github.event_name != 'workflow_dispatch' || (github.event_name == 'workflow_dispatch' && inputs.dev == 'true')) }}
needs: build
runs-on: ubuntu-latest
environment:
name: dev
permissions:
id-token: write
steps:
- name: Checkout apps-repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: octo-sts/action@6177b4481c00308b3839969c3eca88c96a91775f # v1.0.0
id: octo-sts
with:
scope: kartverket/skvis-apps
identity: regelrett-frontend
- name: Checkout skvis-apps
uses: actions/checkout@v4
with:
repository: kartverket/skvis-apps
ref: main
token: ${{ secrets.ARGO_PAT }}
token: ${{ steps.octo-sts.outputs.token }}
- name: Update version
run: |
echo "\"${{ needs.build.outputs.image_url }}\"" > "env/atgcp1-dev/regelrett-main/${{ env.ARGO_VERSION_FILE }}"
git config --global user.email "[email protected]"
git config --global user.name "Regelrett CI"
git commit -am "Update Regelrett frontend ${{ env.ARGO_VERSION_FILE }}"
git commit -am "Update ${{ env.ARGO_VERSION_FILE }}"
git push

0 comments on commit de622aa

Please sign in to comment.