enable AI #49
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 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 }}' | |
} | |
}) |