-
Notifications
You must be signed in to change notification settings - Fork 253
79 lines (65 loc) · 2.89 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
# This workflow will build and publish Action Destination package and trigger a buildkite workflow for updating integrations.
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
name: Publish Canary
on:
workflow_dispatch:
push:
branches:
- add-tar-release-pipeline
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: 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
- name: Set NPM Token
run: |
npm set '//registry.npmjs.org/:_authToken' ${{ secrets.NPM_PUBLISH_TOKEN }}
npm whoami
- name: Publish Action Destinations
run: |
yarn cloud publish --tag canary --new-version "${{ env.ACTION_DESTINATION_VERSION }}" --no-git-tag-version
- name: Trigger Integrations Pipeline
run: |
result=$(curl --request POST \
--url https://api.buildkite.com/v2/organizations/segment/pipelines/integrations/builds \
--header 'Authorization: Bearer ${{ secrets.INTEGRATIONS_BUILDKITE_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"commit":"HEAD","branch":"ci-test",":github: Update action destination version with action-destinations-${{ env.PACKAGE_VERSION }}-${{ env.SHORT_SHA }}","env":{
"ACTIONS_BRANCH": "${{ github.ref_name }}", "TRIGGERED_FROM_GHA": "true", "ACTION_DESTINATION_ARTIFACT": "action-destinations-${{ env.PACKAGE_VERSION }}-${{ env.SHORT_SHA }}.tgz", "ACTIONS_RUN_ID": "${{ github.run_id }}" },"meta_data":{}}')
BUILDKITE_URL=$(echo $result | jq -r '.web_url')
if [[ -z "$BUILDKITE_URL"]];
then
exit 1
else
echo "Build triggered successfuly - ${BUILDKITE_URL}"
fi