Skip to content

add add-tar-release-pipeline-1 to allowed branches for testing #33

add add-tar-release-pipeline-1 to allowed branches for testing

add add-tar-release-pipeline-1 to allowed branches for testing #33

# 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:
- staging
- add-tar-release-pipeline-1
# Manual trigger
workflow_dispatch:
inputs:
buildkite_branch:
description: 'Branch to trigger the Buildkite pipeline on'
default: 'staging'
branch_to_update:
description: 'Branch to update with the new package versions. If a branch with the name is not found, new branch will be created with base as master'
default: 'staging'
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_TO_UPDATE: ${{ github.event.inputs.branch_to_update }}
BUILDKITE_BRANCH: ${{ github.event.inputs.buildkite_branch }}
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