|
| 1 | +name: "Separate build and deploy to dev" |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + project: |
| 6 | + description: "Select the project to build and deploy" |
| 7 | + required: true |
| 8 | + type: choice |
| 9 | + options: |
| 10 | + - cpa-repo |
| 11 | + - ebms-async |
| 12 | + - ebms-payload |
| 13 | + - ebms-provider |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + name: "Build selected project" |
| 18 | + runs-on: "ubuntu-24.04" |
| 19 | + permissions: |
| 20 | + packages: write |
| 21 | + repository-projects: write |
| 22 | + contents: write |
| 23 | + id-token: write |
| 24 | + steps: |
| 25 | + - uses: "actions/checkout@v4" |
| 26 | + - uses: "actions/setup-java@v4" |
| 27 | + with: |
| 28 | + java-version: "21" |
| 29 | + distribution: "temurin" |
| 30 | + - name: Cache gradle wrapper |
| 31 | + uses: actions/cache@v3 |
| 32 | + with: |
| 33 | + path: ~/.gradle/wrapper |
| 34 | + key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} |
| 35 | + - name: Cache Gradle packages |
| 36 | + uses: actions/cache@v3 |
| 37 | + with: |
| 38 | + path: ~/.gradle/caches |
| 39 | + key: ${{ runner.os }}-gradle-cache-${{ hashFiles('build.gradle') }} |
| 40 | + restore-keys: | |
| 41 | + ${{ runner.os }}-gradle-cache- |
| 42 | + - name: "Build and test selected project" |
| 43 | + run: ./gradlew :${{ github.event.inputs.project }}:test :${{ github.event.inputs.project }}:build |
| 44 | + env: |
| 45 | + ORG_GRADLE_PROJECT_githubUser: x-access-token |
| 46 | + ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + |
| 49 | + - name: "Docker build and push selected project" |
| 50 | + uses: nais/docker-build-push@v0 |
| 51 | + id: docker-push |
| 52 | + with: |
| 53 | + team: team-emottak |
| 54 | + tag: ${{ github.sha }} |
| 55 | + dockerfile: Dockerfile |
| 56 | + docker_context: ${{ github.event.inputs.project }} |
| 57 | + image_suffix: ${{ github.event.inputs.project }} |
| 58 | + outputs: |
| 59 | + image: ${{ steps.docker-push.outputs.image }} |
| 60 | + |
| 61 | + deploy: |
| 62 | + name: "Deploy selected project to dev" |
| 63 | + needs: "build" |
| 64 | + runs-on: "ubuntu-24.04" |
| 65 | + permissions: |
| 66 | + contents: read |
| 67 | + id-token: write |
| 68 | + steps: |
| 69 | + - uses: "actions/checkout@v4" |
| 70 | + - name: "Deploy to DEV" |
| 71 | + uses: "nais/deploy/actions/deploy@v2" |
| 72 | + env: |
| 73 | + CLUSTER: "dev-fss" |
| 74 | + RESOURCE: ".nais/${{ github.event.inputs.project }}-dev.yaml" |
| 75 | + IMAGE: ${{ needs.build.outputs.image }} |
0 commit comments