Skip to content

Grant permission to script #27

Grant permission to script

Grant permission to script #27

# 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
- staging
- add-tar-release-pipeline
# Manual trigger
workflow_dispatch:
jobs:
build-and-publish:
env:
HUSKY: 0
runs-on: ubuntu-20.04
timeout-minutes: 15
strategy:
matrix:
node-version: [18.x]
steps:
- name: Fail if branch is main
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
run: |
echo "This workflow should not be triggered with workflow_dispatch on the main branch"
exit 1
- 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 }}
BRANCH_NAME: ${{ github.ref_name }}
RUN_ID: ${{ github.run_id }}}
BUILDKITE_TOKEN: ${{ secrets.BUILDKITE_TOKEN }}
BUILDKITE_PIPELINE_URL: ${{ secrets.BUILDKITE_PIPELINE_URL }}
run: |
chmod +x ./scripts/trigger-buildkite-pipeline.sh
./scripts/trigger-buildkite-pipeline.sh