chore: removed GITHUB_TOKEN from a step where it shouldn't be needed #26
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: "Backend: Build and deploy" | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '**.md' | |
- '**/**.md' | |
- '.gitignore' | |
- 'LICENCE' | |
env: | |
IMAGE_NAME: "ghcr.io/${{ github.repository }}/backend:${{ github.sha }}" | |
NAIS_MANIFEST: "backend.yaml" | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build-and-push: | |
name: Build, push emottak-test-client-backend image | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: temurin | |
- name: "Cache gradle wrapper" | |
uses: actions/cache@v3 | |
with: | |
path: ~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} | |
- name: "Cache Gradle packages" | |
uses: actions/cache@v3 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-cache-${{ hashFiles('build.gradle') }} | |
restore-keys: | | |
${{ runner.os }}-gradle-cache- | |
- name: "Build backend" | |
run: ./gradlew buildBackend | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Login to GitHub Packages Docker Registry" | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Build and push backend docker image" | |
run: | | |
docker build --build-arg GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} --tag ${{ env.IMAGE_NAME }} -f backend/Dockerfile --pull backend | |
docker push ${{ env.IMAGE_NAME }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
deploy-to-dev: | |
name: Deploy emottak-test-client-backend to dev | |
needs: build-and-push | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Deploy backend to dev | |
uses: nais/deploy/actions/deploy@v2 | |
env: | |
CLUSTER: dev-fss | |
RESOURCE: .nais/backend.yaml | |
VAR: image=${{env.IMAGE_NAME}} |