-
Notifications
You must be signed in to change notification settings - Fork 8
103 lines (90 loc) · 3.62 KB
/
build.backend.yaml
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Backend Container Build
on:
push:
branches: [ main ]
paths: ['roshambo-backend/**']
workflow_dispatch:
concurrency:
group: container-build
jobs:
build-backend-container:
runs-on: ubuntu-20.04
outputs:
git-sha: ${{ steps.git-sha.outputs.sha }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Set output for Git short SHA
id: git-sha
run: echo "::set-output name=sha::$(git rev-parse --short HEAD)"
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
cache: 'maven'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build with Maven
run: mvn package -B --no-transfer-progress --file ./roshambo-backend/pom.xml
- name: Login to quay.io
uses: docker/login-action@v3
with:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
registry: quay.io
- name: Build and push images to quay.io
uses: docker/build-push-action@v5
with:
context: ./roshambo-backend
file: ./roshambo-backend/src/main/docker/Dockerfile.jvm
push: true
tags: |
quay.io/rhdevelopers/roshambo-backend:latest
quay.io/rhdevelopers/roshambo-backend:sha-${{ steps.git-sha.outputs.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
#- name: Build and push (ROSHAMBO_ENABLE_CAMERA=true) images to quay.io
# uses: docker/build-push-action@v5
# with:
# context: ./roshambo-backend
# file: ./roshambo-backend/src/main/docker/Dockerfile.jvm
# build-args: |
# ROSHAMBO_ENABLE_CAMERA=true
# push: true
# tags: |
# quay.io/rhdevelopers/roshambo-backend:latest-camera
# quay.io/rhdevelopers/roshambo-backend:sha-${{ steps.git-sha.outputs.sha }}-camera
# cache-from: type=gha
# cache-to: type=gha,mode=max
# https://github.com/orgs/community/discussions/26323#discussioncomment-3251454
# Use the GitHub API to make an authenticated call that triggers a workflow
# in the manifests repository. The targeted workflow opens a PR to use the
# new image that was pushed to quay.io. A personal access token (PAT) is
# required to make the API call. The PAT can be created by a member of the
# redhat-developer-demos org by visiting https://github.com/settings/personal-access-tokens/new
# and selecting "redhat-developer-demos" under resource owner dropdown.
# Select the rps repositories, and then add actions read/write permissions
#
# Set the PAT_TOKEN at https://github.com/redhat-developer-demos/rps-game/settings/secrets/actions
#
# You can manually trigger the action using curl
# curl -X POST \
# -H "Authorization: Bearer $PAT" \
# -H "Accept: application/vnd.github.v3+json" \
# https://api.github.com/repos/redhat-developer-demos/rps-game-manifests/actions/workflows/update-backend-image.yaml/dispatches \
# -d '{"ref":"main", "inputs": { "image": "foo" } }'
- name: Trigger update workflow in the manifests repository
uses: actions/github-script@v6
with:
github-token: ${{ secrets.PAT_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'redhat-developer-demos',
repo: 'rps-game-manifests',
workflow_id: 'update-backend-image.yaml',
ref: 'main',
inputs: {
image: 'quay.io/rhdevelopers/roshambo-backend:sha-${{ steps.git-sha.outputs.sha }}'
}
})