Skip to content

MNT Run workflow on pull-request #16

MNT Run workflow on pull-request

MNT Run workflow on pull-request #16

Workflow file for this run

name: CI
on:
push:
pull_request:
workflow_dispatch:
permissions: {}
jobs:
ci:
# This repo has no tests and nothing to lint, so we can't use regular CI.
# Instead, just directly dispatch tag release on push, and let that figure it out.
name: Dispatch tag patch release
runs-on: ubuntu-latest
if: github.repository_owner == 'silverstripe'
permissions:
actions: write
env:
GITHUB_REPOSITORY: ${{ github.repository }}
BRANCH: ${{ github.ref_name }}
LATEST_LOCAL_SHA: ${{ github.sha }}
steps:
- name: Dispatch tag patch release
shell: bash
id: dispatch-tag-patch-release
run: |
echo "LATEST_LOCAL_SHA is $LATEST_LOCAL_SHA"
# https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event
RESP_CODE=$(curl -w %{http_code} -s -L -o __response.json \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$GITHUB_REPOSITORY/actions/workflows/tag-patch-release.yml/dispatches \
-d "{\"ref\":\"$BRANCH\",\"inputs\":{\"latest_local_sha\":\"$LATEST_LOCAL_SHA\"}}"
)
if [[ $RESP_CODE != "204" ]]; then
echo "Failed to dispatch workflow - HTTP response code was $RESP_CODE"
cat __response.json
exit 1
fi