Skip to content

Commit

Permalink
Add publish automation workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
AhyoungRyu committed Apr 1, 2024
1 parent 8fe834a commit ff168ac
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 19 deletions.
File renamed without changes.
46 changes: 46 additions & 0 deletions .github/workflows/package-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: npm publish
on:
workflow_dispatch:
inputs:
branch_name:
description: 'Type a branch name starting with `release/v`'
required: true

jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check if branch exists
id: check-branch
run: |
if git ls-remote --heads origin ${{ github.event.inputs.branch }} | grep -q refs/heads/${{ github.event.inputs.branch }}; then
echo "Branch exists."
else
echo "Branch does not exist."
exit 1
fi
- uses: actions/setup-node@v3
- name: Install and Build 🔧
run: |
npm install
npm version ${{ github.event.inputs.version }}
cp .env .env.production
echo "VITE_CHAT_AI_WIDGET_KEY=${{ secrets.chat_ai_widget_key }}" >> .env.production
npm run build:pages
- name: 'set environments'
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.npm_token }}" >> .npmrc
git config --global user.email "[email protected]"
git config --global user.name "sendbird-sdk-deployment"
- name: 'build and publish to npm'
run: |
npm publish -access=public
- name: 'create a pull request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create --title "chore(release): publish ${{ github.event.inputs.version }}" --body "created by automation"
19 changes: 0 additions & 19 deletions .github/workflows/pr-comment-bot.yml

This file was deleted.

76 changes: 76 additions & 0 deletions .github/workflows/release-ticket-creation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Release ticket creation on manual workflow trigger
on:
workflow_dispatch:
inputs:
branch_name:
description: 'Type a branch name starting with `release/v`'
required: true

jobs:
trigger-release-ticket-creation:
name: Trigger release ticket creation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Verify branch name
run: |
if [[ ! ${{ github.event.inputs.branch_name }} =~ ^release/v ]]; then
echo "Branch name should start with 'release/v'"
exit 1
fi
- name: Check if branch exists
id: check_branch
run: |
set -x
set -o pipefail
branch_name="${{ github.event.inputs.branch_name }}"
git ls-remote --exit-code --heads origin "$branch_name" | grep -q "$branch_name"
if [[ ${PIPESTATUS[1]} -eq 0 ]]; then
echo "BRANCH_EXISTS=true" >> $GITHUB_ENV
else
echo "BRANCH_EXISTS=false" >> $GITHUB_ENV
fi
- name: Create branch if it doesn't exist
if: steps.check_branch.outputs.branch_exists == 1
run: |
branch_name="${{ github.event.inputs.branch_name }}"
git checkout -b "$branch_name"
git push origin "$branch_name"
- name: Trigger CircleCI Job
run: |
set -x
API_RESULT=$(curl --request POST \
--url "https://circleci.com/api/v2/project/gh/${{ github.repository }}/pipeline" \
--header "Circle-Token: ${{ secrets.CIRCLECI_API_TOKEN }}" \
--header "content-type: application/json" \
--data '{
"branch": "${{ github.event.inputs.branch_name }}",
"parameters": {
"run_workflow_create_ticket": true
}
}')
echo "API_RESULT: ${API_RESULT}"
CIRCLE_CI_JOB_NUMBER=$(echo "${API_RESULT}" | jq -r '.number')
if [[ $? -eq 0 ]]; then
HTTP_STATUS=$(echo "${API_RESULT}" | jq -r '.status')
if [[ $HTTP_STATUS == "success" ]]; then
echo "CircleCI Job Triggered: $CIRCLE_CI_JOB_NUMBER"
echo "DEPLOY_COMMENT_BODY=https://app.circleci.com/pipelines/github/${{ github.repository }}/$CIRCLE_CI_JOB_NUMBER" >> $GITHUB_ENV
echo "JOB_STATUS=success" >> $GITHUB_OUTPUT
else
echo "CircleCI Job Trigger Failed"
echo "JOB_STATUS=failure" >> $GITHUB_OUTPUT
exit 1
fi
else
echo "API request failed"
echo "JOB_STATUS=failure" >> $GITHUB_OUTPUT
exit 1
fi

0 comments on commit ff168ac

Please sign in to comment.