Deploy #387
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: 'Branch to deploy to' | |
required: true | |
default: 'staging' | |
source: | |
description: 'Branch to deploy from' | |
required: true | |
default: 'develop' | |
jobs: | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 18.x | |
registry-url: 'https://registry.npmjs.org' | |
- name: Corepack Enable | |
run: | | |
corepack enable | |
- name: Checkout source | |
run: | | |
git checkout ${{ github.event.inputs.source }} | |
git reset origin/${{ github.event.inputs.source }} --hard | |
- name: Update CHANGELOG | |
run: | | |
CURRENT_DATE="$(date +%-m\/%-d\/%Y)" | |
pwd | |
ls -la | |
sed -i -e "s!#### Date: TBD!#### Date: ${CURRENT_DATE}!g" ./CHANGELOG.md | |
- name: Commit CHANGELOG | |
run: | | |
git config --global user.name DevOps | |
git config --global user.email [email protected] | |
git add ./CHANGELOG.md | |
git commit -m "chore: Update CHANGELOG Date" | |
- name: Merge source into target branch | |
run: | | |
git checkout "${{ github.event.inputs.branch }}" | |
git fetch origin | |
git reset "origin/${{ github.event.inputs.branch }}" --hard | |
git merge -X theirs --no-ff ${{ github.event.inputs.source }} | |
- name: Update package versions | |
run: | | |
if [ "${{ github.event.inputs.branch }}" == "master" ] || [[ "${{ github.event.inputs.branch }}" =~ ^release/.* ]]; then | |
VERSION=$("./script/next_version.sh") | |
else | |
VERSION=$("./script/next_version.sh" "${GITHUB_RUN_ID}") | |
fi | |
echo "Publishing $VERSION" | |
lerna version "$VERSION" --yes --no-push | |
- name: Push changes with tags | |
run: | | |
git remote set-url origin https://x-access-token:${{ secrets.DEPLOY_SECRET }}@github.com/${{ github.repository }} | |
git push origin --follow-tags | |
env: | |
CI: true |