Skip to content

promote-command

promote-command #121

name: Promote
on:
repository_dispatch:
types: [promote-command]
env:
IMAGE_BASE: europe-north1-docker.pkg.dev/nais-management-233d/k9saksbehandling/k9-los-web
jobs:
promote:
runs-on: ubuntu-latest
permissions:
issues: write
packages: write
contents: read
id-token: write
steps:
- name: Henter informasjon fra issuet
id: issue_comment
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.get( {
owner: context.issue.owner,
repo: context.issue.repo,
issue_number: ${{ github.event.client_payload.github.payload.issue.number }} })
.then(response => {
core.setOutput('sha', response.data.body);
core.setOutput('title', response.data.title);
});
- name: Setter IMAGE som brukes i deploy-filen & SHA for kode checkout
env:
CLUSTER_INPUT: ${{ github.event.client_payload.slash_command.args.unnamed.arg1 }}
IMAGE_INPUT: ${{ steps.issue_comment.outputs.title }}
SHA_INPUT: ${{ steps.issue_comment.outputs.sha }}
run: |
echo "IMAGE=$IMAGE_BASE:$(echo $IMAGE_INPUT | awk '{print $NF}')" >> $GITHUB_ENV
echo "SHA=$(echo $SHA_INPUT | awk '{print $NF}')" >> $GITHUB_ENV
echo "CLUSTER=$CLUSTER_INPUT" >> $GITHUB_ENV
- name: Sjekk ut kode
uses: actions/checkout@v4
with:
ref: ${{ env.SHA }}
- name: Deploy k9-los-web til cluster
uses: nais/deploy/actions/deploy@v2
env:
PRINT_PAYLOAD: true
CLUSTER: ${{ env.CLUSTER }}
RESOURCE: nais/k9-los-web.yml
VARS: nais/${{ env.CLUSTER }}.yml
- name: Oppdater kommentar med deployment status ved feil
if: failure()
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const issue = { owner: context.issue.owner,
repo: context.issue.repo,
issue_number: ${{ github.event.client_payload.github.payload.issue.number }} }
github.rest.issues.createComment({...issue, body: 'promote til ${{ env.CLUSTER }} feilet'})
github.rest.issues.addLabels({...issue, labels: ['deployment-failed','${{ env.CLUSTER }}']})
- name: Oppdater kommentar med deployment status
if: success()
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const issue = { owner: context.issue.owner,
repo: context.issue.repo,
issue_number: ${{ github.event.client_payload.github.payload.issue.number }} }
github.rest.issues.createComment({...issue, body: 'promote til ${{ env.CLUSTER }} utført'})
github.rest.issues.addLabels({...issue, labels: ['deployment','${{ env.CLUSTER }}']})