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 deploy omsorgsopptjening-start-innlesning til prod-gcp | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
tag_build_and_deploy: | |
name: 'Build, deploy and tag' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
steps: | |
# PULLER REPO | |
- name: 'Pull repo' | |
uses: actions/[email protected] | |
# SETTER DATO OG COMMIT VARIABEL | |
- name: 'Setter dato og commit variabel' | |
run: | | |
export TZ=CET | |
echo "DATE=$(date "+%Y-%m-%d--%H-%M-%S")" >> $GITHUB_ENV | |
echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV | |
# SETTER IMAGE VARIABEL | |
- name: 'Setting Image Variabel' | |
run: echo "IMAGE=docker.pkg.github.com/${{ github.repository }}/omsorgsopptjening-start-innlesning:${{ env.DATE }}---${{ env.COMMIT_HASH }}" >> $GITHUB_ENV | |
# SETTER IMAGE GHCR VARIABEL | |
- name: 'Setting Image ghcr Variabel' | |
run: echo "IMAGE_GHCR=ghcr.io/${{ github.repository }}/omsorgsopptjening-start-innlesning:${{ env.DATE }}---${{ env.COMMIT_HASH }}" >> $GITHUB_ENV | |
# JAVA 21 | |
- name: 'Java 21' | |
uses: actions/[email protected] | |
with: | |
distribution: 'temurin' | |
java-version: 21 | |
cache: 'gradle' | |
# BYGGER DOCKER CONTAINER | |
- name: 'Bygg og publiser docker image' | |
run: | | |
./gradlew build | |
docker build --tag ${{ env.IMAGE }} . | |
docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} -p ${{ secrets.GITHUB_TOKEN }} | |
docker push ${{ env.IMAGE }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# DEPLOYER prod-gcp | |
- name: 'Deploy omsorgsopptjening-start-innlesning to prod-gcp' | |
uses: nais/deploy/actions/deploy@v2 | |
env: | |
RESOURCE: nais/prod-gcp.yml,nais/unleash-apitoken-prod-gcp.yml | |
CLUSTER: prod-gcp | |
IMAGE: ${{ env.IMAGE_GHCR }} |