Skip to content

Commit

Permalink
Add canary release pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
varadarajan-tw committed Oct 17, 2023
1 parent e4fd79b commit c511f2a
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions .github/workflows/publish-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
# Remove before merging to master
- add-tar-release-pipeline
- stage
- staging
# Manual trigger
workflow_dispatch:
# branches:
Expand Down Expand Up @@ -51,14 +51,6 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Get Package Version
run: |
PACKAGE_VERSION=$(node -p "require('./packages/destination-actions/package.json').version")
SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
echo "SHORT_SHA=${SHORT_SHA}" >> $GITHUB_ENV
echo "ACTION_DESTINATION_VERSION=${PACKAGE_VERSION}-${SHORT_SHA}" >> $GITHUB_ENV
- name: Build
run: |
NODE_ENV=production yarn build
Expand All @@ -69,21 +61,28 @@ jobs:
npm whoami
- name: Publish Canary Packages
id: publish-packages
run: |
yarn lerna publish --canary --preid $(git branch --show-current) --no-push --no-git-tag-version
yarn lerna publish -y --canary --preid "$(git branch --show-current).$(git rev-parse --short HEAD)" --no-push --no-git-tag-version --summary-file
echo "ACTION_DESTINATIONS_VERSION=$(jq -r '.[] | select(.packageName == "@segment/action-destinations") | .version' lerna-publish-summary.json)" >> "$GITHUB_OUTPUT"
echo "ACTIONS_CORE_VERSION=$(jq -r '.[] | select(.packageName == "@segment/actions-core") | .version' lerna-publish-summary.json)" >> "$GITHUB_OUTPUT"
- name: Trigger Buildkite Pipeline
if: ${{ steps.publish-packages.outputs.ACTION_DESTINATIONS_VERSION != null && steps.publish-packages.outputs.ACTIONS_CORE_VERSION != null }}
env:
ACTION_DESTINATIONS_VERSION: ${{ steps.publish-packages.outputs.ACTION_DESTINATIONS_VERSION }}
ACTIONS_CORE_VERSION: ${{ steps.publish-packages.outputs.ACTIONS_CORE_VERSION }}
run: |
result=$(curl --request POST \
--url "${{ vars.BUILDKITE_PIPELINE_URL }}" \
--header 'Authorization: Bearer ${{ secrets.BUILDKITE_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"commit":"HEAD","branch":"ci-test", "message": "Triggered from :github: run ${{ github.run_id }}: Upgrade action-destination packages ${{ env.ACTION_DESTINATION_VERSION }}","env":{
"BRANCH_TO_UPDATE": "${{ github.ref_name }}", "SHORT_SHA": "${{ env.SHORT_SHA }}", "WEEKLY_DEPLOY": "false", "UPGRADE_ACTION_DESTINATIONS": "true", "ACTION_DESTINATIONS_VERSION": "${{ env.ACTION_DESTINATION_VERSION }}", "ACTIONS_RUN_ID": "${{ github.run_id }}" },"meta_data":{}}')
--data '{"commit":"HEAD","branch":"ci-test", "message": ":github: Triggered from Github Actions Run: ${{ github.run_id }}","env":{
"BRANCH_TO_UPDATE": "${{ github.ref_name }}", "ACTIONS_RELEASE": "true", "CREATE_PR": "false", "UPGRADE_ACTION_DESTINATIONS": "true", "ACTION_DESTINATIONS_VERSION": "${{ env.ACTION_DESTINATIONS_VERSION }}", "ACTIONS_CORE_VERSION": "${{ env.ACTIONS_CORE_VERSION }}", "ACTIONS_RUN_ID": "${{ github.run_id }}" },"meta_data":{}}')
BUILDKITE_URL=$(echo $result | jq -r '.web_url')
if [[ ${BUILDKITE_URL} -eq null ]]; then
echo "Failed to trigger Buildkite pipeline. Reason:$(echo $result | jq -r '.message'))"
if [[ "${BUILDKITE_URL}" -eq null ]]; then
echo "Failed to trigger Buildkite pipeline. Reason:$(echo $result | jq -r '.message')"
exit 1
else
echo "Buildkite pipeline triggered successfully - ${BUILDKITE_URL}"
echo "Buildkite pipeline triggered successfully."
fi

0 comments on commit c511f2a

Please sign in to comment.