Skip to content

Rollback Prod

Rollback Prod #36

Workflow file for this run

name: Rollback Prod
on:
release:
types: [deleted]
env:
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
SENTRY_AUTH_TOKEN: ${{secrets.SENTRY_AUTH_TOKEN}}
RELEASE_SLACK_WEB_HOOK_URL: ${{secrets.RELEASE_SLACK_WEB_HOOK_URL}}
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID_PROD}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY_PROD}}
AWS_REGION: ${{secrets.AWS_REGION}}
CI: true
IS_RELEASE: true
jobs:
rollback-prod:
runs-on: ubuntu-latest
name: Rollback
steps:
- name: Get Tag
uses: olegtarasov/[email protected]
id: tagName
with:
tagRegex: '(?<package>.*)_(?<version>.*)'
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set Node
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install
run: yarn install && git checkout -- .
- name: Package name Set
run: |
PACKAGE_NAME=$(yarn json -f packages/${{ steps.tagName.outputs.package }}/package.json name)
echo $PACKAGE_NAME
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
- name: Previous Version Declare
run: |
PREVIOUS_VERSION=$(git tag --list --sort=committerdate | grep -i $PACKAGE_NAME | tail -2 | grep -vw "$PACKAGE_NAME"_${{ steps.tagName.outputs.version }})
echo $PREVIOUS_VERSION
echo "PREVIOUS_VERSION=$PREVIOUS_VERSION" >> $GITHUB_ENV
echo "previous version === $PREVIOUS_VERSION"
- name: Checkout Previous Version
run: git checkout $PREVIOUS_VERSION
- name: Package or Service
run: |
IS_PACKAGE=$(echo $PACKAGE_NAME | grep -o "@reapit/" | wc -l)
echo "package: $PACKAGE_NAME is $IS_PACKAGE"
- name: Fetch config
run: |
yarn workspace ${{ steps.tagName.outputs.package }} run conf --name production
- name: Build
run: |
yarn workspace ${{ steps.tagName.outputs.package }} run build
- name: Release
run: |
yarn workspace ${{ steps.tagName.outputs.package }} run release --stage prod
- name: NPM Rollback
run: |
test $IS_PACKAGE == 1 &&
yarn npm tag remove $PACKAGE_NAME latest &&
yarn npm tag add $PACKAGE_NAME@$PREVIOUS_VERSION latest &&
yarn npm tag ls || exit 0