Prod deploy of main #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Manual deploy to prod | |
| on: | |
| workflow_call: | |
| workflow_dispatch: | |
| run-name: Prod deploy of ${{ github.ref_name }} | |
| jobs: | |
| deploy_to_prod: | |
| name: Deploy | |
| if: github.ref == 'refs/heads/main' | |
| permissions: | |
| contents: write | |
| id-token: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| name: Checkout code | |
| - name: Get image registry | |
| id: image-registry | |
| uses: nais/login@v0 | |
| with: | |
| team: klage | |
| - name: Generate image name | |
| id: image | |
| shell: bash | |
| run: echo "image=${{ steps.image-registry.outputs.registry }}/kabal-smart-editor-api:${{ github.sha }}" >> $GITHUB_OUTPUT | |
| - name: Deploy to prod | |
| uses: nais/deploy/actions/deploy@v2 | |
| env: | |
| TEAM: klage | |
| CLUSTER: prod-gcp | |
| TIMEOUT: 20m | |
| VARS: deploy/prod.yaml | |
| RESOURCE: deploy/nais.yaml | |
| VAR: image=${{ steps.image.outputs.image }} | |
| IMAGE: ${{ steps.image.outputs.image }} | |
| - name: Generate release version | |
| id: version | |
| run: | | |
| TIME=$(TZ="Europe/Oslo" date +%Y.%m.%d-%H.%M) | |
| COMMIT=$(git rev-parse --short=7 HEAD) | |
| VERSION=$TIME-$COMMIT | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| - uses: ncipollo/release-action@main | |
| with: | |
| tag: ${{ steps.version.outputs.version }} | |
| - name: Post failures to Slack | |
| if: failure() | |
| run: | | |
| curl -X POST --data-urlencode "payload={\"channel\": \"$CHANNEL\", \"text\": \"$MESSAGE\", \"icon_emoji\": \":ghost:\"}" $WEBHOOK_URL | |
| env: | |
| MESSAGE: "Deploy til prod feilet" | |
| CHANNEL: "#klage-notifications" | |
| WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} |