-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: check on pr * chore: add check on pr * fix: fix location * chore: set up deploy ci * fix: skip steps when nothing to check * perf: remove debugging echo
- Loading branch information
1 parent
feeb7ad
commit 8cae563
Showing
3 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Build an image | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
configuration: | ||
required: true | ||
type: string | ||
registry: | ||
required: true | ||
type: string | ||
repo: | ||
required: true | ||
type: string | ||
|
||
env: | ||
REGISTRY: ${{ inputs.registry }} | ||
REPO: ${{ inputs.repo }} | ||
|
||
jobs: | ||
build: | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Extract configurations | ||
id: extract-configurations | ||
run: | | ||
echo "context=$(cat ${{ inputs.configuration }} | jq -r .context)" >> ${GITHUB_OUTPUT} | ||
echo "name=$(cat ${{ inputs.configuration }} | jq -r .name)" >> ${GITHUB_OUTPUT} | ||
echo "tag=$(cat ${{ inputs.configuration }} | jq -r .tag)" >> ${GITHUB_OUTPUT} | ||
export build_args=$(cat ${{ inputs.configuration }} | jq -r .build_args) | ||
{ | ||
echo "buildargs<<EOF" | ||
for key in $(cat ${{ inputs.configuration }} | jq -r '.build_args | keys | .[]'); do | ||
echo "${key}=$(cat ${{ inputs.configuration }} | jq -r ".build_args.${key}")" | ||
done | ||
echo "EOF" | ||
} >> ${GITHUB_OUTPUT} | ||
- uses: docker/setup-buildx-action@v3 | ||
- uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: docker/build-push-action@v5 | ||
with: | ||
context: ${{ steps.extract-configurations.outputs.context }} | ||
file: ${{ steps.extract-configurations.outputs.context }}/Dockerfile | ||
platforms: linux/amd64 | ||
push: true | ||
tags: | | ||
${{ env.REGISTRY }}/${{ env.REPO }}/${{ steps.extract-configurations.outputs.name }}:${{ steps.extract-configurations.outputs.tag }} | ||
build-args: ${{ steps.extract-configurations.outputs.buildargs }} | ||
labels: | | ||
org.opencontainers.image.source="https://github.com/${{ env.REPO }}" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: Check configurations | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
|
||
find-configurations: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Find configurations | ||
id: find-targets | ||
run: | | ||
configures=$(git diff --name-only origin/main...HEAD -- configures | grep -e "\.json" | xargs -I{e} echo \"{e}\" | tr '\n' ',' | sed 's/,$//') | ||
echo "configures=[${configures}]" >> ${GITHUB_OUTPUT} | ||
outputs: | ||
configures: ${{ steps.find-targets.outputs.configures }} | ||
|
||
check-configurations: | ||
needs: | ||
- find-configurations | ||
|
||
if: needs.find-configurations.outputs.configures != '[]' | ||
|
||
strategy: | ||
matrix: | ||
configure: ${{ fromJson(needs.find-configurations.outputs.configures) }} | ||
|
||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Check the configuration file exists | ||
run: test -f ${{ matrix.configure }} && [[ -s ${{ matrix.configure }} ]] | ||
- name: Check the configuration file is valid JSON | ||
run: jq . ${{ matrix.configure }} > /dev/null | ||
|
||
check-all-test-passed: | ||
if: always() | ||
|
||
needs: | ||
- check-configurations | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- run: exit 1 | ||
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} | ||
- uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: ':mega: All tests passed!' | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Build engine images and publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
|
||
find-configurations: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
- name: Find configurations | ||
id: find-targets | ||
run: | | ||
configures=$(git diff --name-only HEAD^...HEAD -- configures | grep -e "\.json" | xargs -I{e} echo \"{e}\" | tr '\n' ',' | sed 's/,$//') | ||
echo "configures=[${configures}]" >> ${GITHUB_OUTPUT} | ||
outputs: | ||
configures: ${{ steps.find-targets.outputs.configures }} | ||
|
||
build-and-publish: | ||
needs: | ||
- find-configurations | ||
|
||
if: needs.find-configurations.outputs.configures != '[]' | ||
|
||
strategy: | ||
matrix: | ||
configure: ${{ fromJson(needs.find-configurations.outputs.configures) }} | ||
uses: ./.github/workflows/build.yaml | ||
with: | ||
configuration: ${{ matrix.configure }} | ||
registry: ghcr.io | ||
repo: kupl/kaprese-engines |