-
Notifications
You must be signed in to change notification settings - Fork 253
88 lines (75 loc) · 3.61 KB
/
publish-canary.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# This workflow will build and publish Action Destination package and trigger a buildkite workflow.
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
name: Publish Canary
on:
push:
branches:
# Remove before merging to master
- add-tar-release-pipeline
- staging
# Manual trigger
workflow_dispatch:
# branches:
# - add-tar-release-pipeline
# # inputs:
# # service_branch:
# # description: 'The service branch to update. If a branch is not present, a new branch will be created.'
# # required: true
# # default: 'stage'
jobs:
build-and-publish:
env:
HUSKY: 0
runs-on: ubuntu-20.04
timeout-minutes: 15
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GH_PAT }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
cache: yarn
- name: Use Github Personal Access Token
run: git config --global url."https://${{ secrets.GH_PAT }}@github.com/".insteadOf ssh://[email protected]/
- name: Install Dependencies
run: yarn install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Build
run: |
NODE_ENV=production yarn build
- name: Set NPM Token
run: |
npm set '//registry.npmjs.org/:_authToken' ${{ secrets.NPM_PUBLISH_TOKEN }}
npm whoami
- name: Publish Canary Packages
id: publish-packages
run: |
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": ":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')"
exit 1
else
echo "Buildkite pipeline triggered successfully."
fi