Update GH Workflow #39
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: Commit Stage | |
on: push | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: thomasvitale/devex/book-service | |
VERSION: latest | |
jobs: | |
build: | |
name: Build and Test | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: read | |
security-events: write | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: liberica | |
java-version: 21 | |
cache: gradle | |
- name: Build, unit tests and integration tests | |
run: | | |
cd 06-knative/basic/book-service | |
chmod +x gradlew | |
./gradlew build | |
package: | |
name: Package and Publish | |
if: ${{ github.ref == 'refs/heads/main' }} | |
needs: [ build ] | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: read | |
packages: write | |
security-events: write | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: liberica | |
java-version: 21 | |
cache: gradle | |
- name: Build container image | |
run: | | |
cd 06-knative/basic/book-service | |
chmod +x gradlew | |
./gradlew bootBuildImage \ | |
--imageName ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} | |
- name: Log into container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.MY_SECRET }} | |
- name: Publish container image | |
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} |