Merge pull request #28 from navikt/spraak #33
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/** | |
- README.md | |
- howto.md | |
permissions: | |
contents: write | |
packages: write | |
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' | |
- 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 }} | |
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 |