Build&deploy to dev and prod #1892
This file contains 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: Build&deploy to dev and prod | |
on: | |
push: | |
branches: | |
- 'main' | |
env: | |
VERSION: familie-ba-sak-frontend:${{ github.sha }} | |
jobs: | |
build: | |
name: Build and push Docker container | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
outputs: | |
image: ${{ steps.docker-build-push.outputs.image }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: yarn | |
registry-url: "https://npm.pkg.github.com" | |
- name: Yarn install | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} | |
run: yarn --prefer-offline --frozen-lockfile | |
- name: Build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_RELEASE: ${{ github.sha }} | |
run: | | |
yarn build | |
yarn test | |
yarn run cypress | |
- name: Push docker image to GAR | |
uses: nais/docker-build-push@v0 | |
id: docker-build-push | |
with: | |
pull: true # optional, default false | |
team: teamfamilie | |
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} # Provided as Organization Secret | |
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} # Provided as Organization Variable | |
deployDev: | |
name: Deploy to gcp-dev | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Deploy til dev-gcp team namespace | |
uses: nais/deploy/actions/deploy@v2 | |
env: | |
CLUSTER: dev-gcp | |
RESOURCE: build_n_deploy/naiserator/gcp-dev.yaml | |
VAR: image=${{ needs.build.outputs.image }},VERSION=${{ env.VERSION }} | |
deployProd: | |
name: Deploy to gcp-prod | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Deploy til prod-gcp team namespace | |
uses: nais/deploy/actions/deploy@v2 | |
env: | |
CLUSTER: prod-gcp | |
RESOURCE: build_n_deploy/naiserator/gcp-prod.yaml | |
VAR: image=${{ needs.build.outputs.image }},VERSION=${{ env.VERSION }} | |
loggfeil: | |
name: Send logg til slack ved feil | |
runs-on: ubuntu-latest | |
needs: [deployProd] | |
if: failure() | |
steps: | |
- name: Send logg til slack ved feil | |
run: | | |
curl -X POST --data "{\"text\": \"Deploy av $GITHUB_REPOSITORY feilet - $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\"}" $WEBHOOK_URL | |
env: | |
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |