Skip to content
This repository was archived by the owner on Aug 20, 2025. It is now read-only.

Commit 956b3e3

Browse files
committed
Deploy to prod action
1 parent 4088359 commit 956b3e3

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

.github/workflows/test-and-build.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,47 @@ jobs:
102102
workflow_id: '${{ secrets.INTEGRATION_TEST_WORKFLOW }}.yaml',
103103
ref: 'main'
104104
})
105+
106+
107+
revoke:
108+
runs-on: ubuntu-latest
109+
needs: build
110+
steps:
111+
- uses: actions/checkout@v4
112+
- name: Mark older approvals as unnecessary
113+
env:
114+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
115+
run: |
116+
# Find previous workflow runs for the same workflow
117+
runs=$(gh run list --workflow=87753572 --json databaseId,status --jq '.[] | select(.status == "waiting") | .databaseId')
118+
119+
for run_id in $runs; do
120+
echo "Marking workflow run $run_id as outdated"
121+
gh run cancel $run_id
122+
done
123+
124+
deploy:
125+
name: Deploy to production
126+
runs-on: ubuntu-latest
127+
needs: [build, revoke]
128+
environment: prod
129+
permissions:
130+
contents: read
131+
id-token: write
132+
133+
steps:
134+
- name: Call workflow
135+
uses: actions/github-script@v7
136+
with:
137+
github-token: ${{ secrets.DEPLOY_PAT }}
138+
script: |
139+
await github.rest.actions.createWorkflowDispatch({
140+
owner: 'statisticsnorway',
141+
repo: '${{ secrets.DEPLOY_REPO }}',
142+
workflow_id: '${{ secrets.DEPLOY_WORKFLOW }}.yaml',
143+
ref: 'master',
144+
inputs: {
145+
environment: "PROD",
146+
service: "datastores-info-service"
147+
}
148+
})

0 commit comments

Comments
 (0)