Tillater ung-sak å skrive til privat-k9-produksjonsstyring-sak-v1 #1540
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 Master | |
on: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- '**.md' | |
- '.gitignore' | |
- 'LICENSE' | |
- 'CODEOWNERS' | |
- 'nais/alerts/**' | |
- '.github/workflows/deploy-alerts.yml' | |
env: | |
BASE_IMAGE: ghcr.io/${{ github.repository }} | |
jobs: | |
Build: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: write # for gradle dep submission | |
issues: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v3 | |
with: | |
java-version: 21 | |
distribution: temurin | |
cache: gradle | |
- name: Setup Gradle to generate and submit dependency graphs | |
uses: gradle/gradle-build-action@v2 | |
with: | |
dependency-graph: generate-and-submit | |
- name: Run a build, generating the dependency graph snapshot which will be submitted | |
run: ./gradlew build | |
env: | |
GITHUB_TOKEN: ${{ secrets.READER_TOKEN }} | |
- name: Kjør tester & bygg JAR | |
run: ./gradlew test shadowjar | |
env: | |
GITHUB_TOKEN: ${{ secrets.READER_TOKEN }} | |
- uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.REPOSITORY_OWNER }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Sett tag for docker image | |
run: echo "TAG=$(date "+%Y.%m.%d")-$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: Bygg & last opp Docker image | |
run: | | |
docker build --pull --tag ${BASE_IMAGE}:${TAG} --tag ${BASE_IMAGE}:latest . | |
docker push ${BASE_IMAGE} --all-tags | |
- name: Sett image for nais deploy | |
run: echo "IMAGE=${BASE_IMAGE}:${TAG}" >> $GITHUB_ENV | |
- name: Lukk gamle issues | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.rest.issues.listForRepo({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'open', | |
labels: ['deployment'] | |
}).then(response => { | |
response.data.forEach(issue => { | |
github.rest.issues.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue.number, | |
state: 'closed' | |
}); | |
}); | |
}); | |
- name: Opprett deployment issue | |
id: createdeployissue | |
if: success() | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
github.rest.issues.create( { | |
owner: context.issue.owner, | |
repo: context.issue.repo, | |
labels: ['deployment'], | |
body: '${{ github.sha }}', | |
title: 'Deploy av ${{ env.TAG }}'}) | |
.then(response => { | |
core.setOutput('number', response.data.number); | |
}); | |
- name: Deploy til preprod | |
uses: nais/deploy/actions/deploy@v1 | |
env: | |
APIKEY: ${{ secrets.DEPLOY_KEY }} | |
CLUSTER: dev-fss | |
RESOURCE: nais/dev-fss.yml | |