This repository has been archived by the owner on Jan 9, 2024. It is now read-only.
Merge pull request #253 from navikt/oppdatere-ingen-saker #171
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: Bygg og publiser docker-image for main | |
on: | |
push: | |
branches: | |
- master | |
- main | |
paths-ignore: | |
- .github/workflows/** | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
image: ${{ env.IMAGE }} | |
steps: | |
- name: Sjekk ut koden | |
uses: actions/checkout@v2 | |
- name: Setup java | |
uses: actions/setup-java@v1 | |
with: | |
java-version: '17.x' | |
- uses: "actions/setup-node@v3" | |
with: | |
node-version: 16 | |
- name: Finn cache-variabler | |
uses: navikt/pb-common-gh-actions/cache-prep@v2 | |
- name: Sett opp cache | |
uses: actions/cache@v2 | |
with: | |
path: | | |
${{ env.CACHE_PATHS }} | |
key: ${{ runner.os }}${{ env.CACHE_KEY_NAMESPACE }}${{ hashFiles(env.CACHE_KEY_HASHED_PATH) }} | |
- name: Bygg prosjekt og kjør tester | |
uses: navikt/pb-common-gh-actions/build@v2 | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Bygg, tag og push Docker image | |
uses: navikt/pb-common-gh-actions/docker-publish@v2 | |
with: | |
TAG_LATEST: "true" | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Tag release i git-repo-et | |
run: | | |
TAG="$(git log -1 --pretty='%ad' --date=format:'%Y%m%d%H%M%S')-$(git log -1 --pretty='%h')" | |
git config user.name "Team Personbruker CI" | |
git config user.email "personbruker@nav.no" | |
git tag $TAG | |
git push origin $TAG | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
matrix: | |
cluster: [dev-gcp, prod-gcp] | |
steps: | |
- name: Sjekk ut koden | |
uses: actions/checkout@v2 | |
- name: 'Sjekk om deploy til ${{ matrix.cluster }} er mulig' | |
run: echo "DEPLOY_CONFIG_DEFINED=$([[ -f ./nais/${{ matrix.cluster }}/nais.yaml ]] && echo 'true' || echo 'false')" >> $GITHUB_ENV | |
- name: 'Deploy-er til ${{ matrix.cluster }}' | |
if: env.DEPLOY_CONFIG_DEFINED == 'true' | |
uses: 'nais/deploy/actions/deploy@v1' | |
env: | |
REF: ${{ github.sha }} | |
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | |
CLUSTER: ${{ matrix.cluster }} | |
RESOURCE: ./nais/${{ matrix.cluster }}/nais.yaml | |
VAR: version=${{ needs.build.outputs.image }} | |
PRINT_PAYLOAD: true |