-
Notifications
You must be signed in to change notification settings - Fork 22
61 lines (59 loc) · 1.69 KB
/
commit-stage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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 Java
uses: actions/setup-java@v4
with:
java-version: 21
distribution: liberica
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 Java
uses: actions/setup-java@v4
with:
java-version: 21
distribution: liberica
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: Authenticate with the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.IMAGE_PUSH_TOKEN }}
- name: Publish container image
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}