Release - Mainnet #57
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: Release - Mainnet | |
on: | |
workflow_dispatch: | |
inputs: | |
bumpType: | |
description: 'Bump version' | |
required: true | |
default: 'patch' | |
type: choice | |
options: | |
- 'patch' | |
- 'minor' | |
- 'major' | |
jobs: | |
bump: | |
runs-on: ubuntu-latest | |
environment: | |
name: mainnet | |
url: https://app.v2.jediswap.xyz/ | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: 'yarn' | |
- name: Automated Version Bump | |
uses: phips28/gh-action-bump-version@v9.1.4 | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} | |
with: | |
version-type: ${{ inputs.bumpType }} | |
tag-prefix: 'v' | |
target-branch: 'main' | |
commit-message: 'CI: bumps version to {{version}}' | |
bump-policy: 'last-commit' | |
cleanup: | |
runs-on: ubuntu-latest | |
needs: [bump] | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Cleanup | |
run: | | |
gh extension install actions/gh-actions-cache | |
REPO=${{ github.repository }} | |
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge" | |
echo "Fetching list of cache key" | |
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 ) | |
## Setting this to not fail the workflow while deleting cache keys. | |
set +e | |
echo "Deleting caches..." | |
for cacheKey in $cacheKeysForPR | |
do | |
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm | |
done | |
echo "Done" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build: | |
runs-on: ubuntu-latest | |
needs: [cleanup] | |
environment: | |
name: mainnet | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn install --immutable | |
- name: Build Project | |
run: yarn build | |
env: | |
CI: false | |
RELEASE_TYPE: 'PRODUCTION' | |
- name: Configure AWS | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Deploy app build to S3 bucket | |
run: aws s3 sync ./build/ s3://$BUCKET_NAME | |
env: | |
BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }} | |
- name: Run Cache Invalidation | |
run: aws cloudfront create-invalidation --distribution-id $CDN_DISTRIBUTION_ID --paths /\* | |
env: | |
CDN_DISTRIBUTION_ID: ${{ secrets.AWS_CDN_DISTRIBUTION_ID }} |