-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #479 from YOU54F/ci/ffi_upgrade
ci: update pact ffi on release workflow
- Loading branch information
Showing
3 changed files
with
86 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,21 @@ | ||
name: Update Pact FFI Library | ||
|
||
on: | ||
repository_dispatch: | ||
types: | ||
- pact-ffi-released | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- run: | | ||
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||
git config --global user.name "${GITHUB_ACTOR}" | ||
git config pull.ff only | ||
- run: script/create-pr-to-update-pact-ffi.sh ${{ github.event.client_payload.version }} | ||
env: | ||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
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,27 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
: "${1?Please supply the pact-ffi version to upgrade to}" | ||
|
||
FFI_VERSION=$1 | ||
TYPE=${2:-fix} | ||
DASHERISED_VERSION=$(echo "${FFI_VERSION}" | sed 's/\./\-/g') | ||
BRANCH_NAME="chore/upgrade-to-pact-ffi-${DASHERISED_VERSION}" | ||
|
||
git checkout master | ||
git checkout src/ffi/index.ts | ||
git pull origin master | ||
|
||
git checkout -b ${BRANCH_NAME} | ||
|
||
cat src/ffi/index.ts | sed "s/export const PACT_FFI_VERSION.*/export const PACT_FFI_VERSION = '${FFI_VERSION}';/" > tmp-install | ||
mv tmp-install src/ffi/index.ts | ||
|
||
git add src/ffi/index.ts | ||
git commit -m "${TYPE}: update pact-ffi to ${FFI_VERSION}" | ||
git push --set-upstream origin ${BRANCH_NAME} | ||
|
||
gh pr create --title "${TYPE}: update pact-ffi to ${FFI_VERSION}" --fill | ||
|
||
git checkout master |
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,38 @@ | ||
#!/bin/sh | ||
|
||
# Script to trigger an update of the pact ffi from pact-foundation/pact-reference to listening repos | ||
# Requires a Github API token with repo scope stored in the | ||
# environment variable GITHUB_ACCESS_TOKEN_FOR_PF_RELEASES | ||
|
||
: "${GITHUB_ACCESS_TOKEN_FOR_PF_RELEASES:?Please set environment variable GITHUB_ACCESS_TOKEN_FOR_PF_RELEASES}" | ||
|
||
if [ -n "$1" ]; then | ||
name="\"${1}\"" | ||
else | ||
echo "name not provided as first param" | ||
exit 1 | ||
fi | ||
|
||
if [ -n "$2" ]; then | ||
version="\"${2}\"" | ||
else | ||
echo "name not provided as second param" | ||
exit 1 | ||
fi | ||
|
||
repository_slug=$(git remote get-url origin | cut -d':' -f2 | sed 's/\.git//') | ||
|
||
output=$(curl -v https://api.github.com/repos/${repository_slug}/dispatches \ | ||
-H 'Accept: application/vnd.github.everest-preview+json' \ | ||
-H "Authorization: Bearer $GITHUB_ACCESS_TOKEN_FOR_PF_RELEASES" \ | ||
-d "{\"event_type\": \"pact-ffi-released\", \"client_payload\": {\"name\": ${name}, \"version\" : ${version}}}" 2>&1) | ||
|
||
if ! echo "${output}" | grep "HTTP\/.* 204" > /dev/null; then | ||
echo "$output" | sed "s/${GITHUB_ACCESS_TOKEN_FOR_PF_RELEASES}/********/g" | ||
echo "Failed to trigger update" | ||
exit 1 | ||
else | ||
echo "Update workflow triggered" | ||
fi | ||
|
||
echo "See https://github.com/${repository_slug}/actions?query=workflow%3A%22Update+Pact+FFI+Library%22" |