Skip to content

Sample commit

Sample commit #38

name: Cloud Tests Trigger
on:
pull_request_target:
branches:
- main
paths-ignore:
- ".mvn/**"
- "docs/**"
- ".github/workflows/build-manual.yml"
- ".github/workflows/shared-wildfly-build.yml"
- '.gitattributes'
- '.gitignore'
- '.gitleaks.toml'
- 'build.bat'
- 'build.sh'
- "CODE_OF_CONDUCT.md"
- "CONTRIBUTING.md"
- "integration-tests.bat"
- "integration-tests.sh"
- "LICENSE.txt"
- "mvnw"
- "mvnw.cmd"
- "README.md"
- "SECURITY.md"
- "**/README.md"
- "**/README.adoc"
# Only run the latest job
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
env:
# Repository where the cloud tests will be run
REPOSITORY: wildfly-extras/wildfly-cloud-tests
# This must be set to a PAT with 'repo' permission for the target repository
TOKEN: ${{ secrets.CLOUD_TESTS_REMOTE_DISPATCH_TOKEN }}
# Just an identifier for the event - this one triggers the cloud tests
EVENT_TYPE: trigger-cloud-tests-pr
permissions: {}
jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- name: Remote Dispatch
env:
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
if: ${{ env.TOKEN }}
run: |
echo $GITHUB_REPOSITORY
echo "FILENAME=$FILENAME" >> $GITHUB_ENV
PR_NUMBER="${{github.event.number}}"
CLIENT_PAYLOAD=$( jq -n \
--arg tr "$GITHUB_REPOSITORY" \
--arg githubSha "$GITHUB_SHA" \
--arg prHeadSha "$PR_HEAD_SHA" \
--arg pr "PR_NUMBER" \
'{triggerRepo: $tr, githubSha: $githubSha, prHeadSha: $prHeadSha, pr: $pr}' )
echo "CLIENT_PAYLOAD: $CLIENT_PAYLOAD"
set -x
resp=$(curl -X POST -s "https://api.github.com/repos/${REPOSITORY}/dispatches" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${TOKEN}" \
-d "{\"event_type\": \"${EVENT_TYPE}\", \"client_payload\": ${CLIENT_PAYLOAD} }")
set +x
if [ -z "$resp" ]
then
sleep 2
else
echo "Workflow failed to trigger"
echo "$resp"
exit 1
fi