Skip to content

Commit

Permalink
Merge branch 'main' into mvenkatakrishnan/prod_deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
manasaV3 authored Feb 22, 2024
2 parents fbf82c9 + f208407 commit 4cb6a2f
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 2 deletions.
101 changes: 99 additions & 2 deletions .github/workflows/prod-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,110 @@
name: Deploy to prod

on:
workflow_dispatch:
schedule:
# Weekdays Mon-Fri @ 18:00 UTC (10AM PST [winter] / 11AM PDT [summer])
- cron: '0 18 * * 1-5'
permissions:
contents: write
id-token: write
contents: read
pull-requests: write

jobs:
create-frontend-release:
concurrency:
group: create-frontend-release-${{ github.ref }}
cancel-in-progress: true

outputs:
pr: ${{ steps.release.outputs.pr }}
prs_created: ${{ steps.release.outputs.prs_created }}

name: generate frontend changelog
runs-on: ubuntu-latest
if: github.repository == 'chanzuckerberg/cryoet-data-portal'
steps:
- name: create changelog
uses: google-github-actions/release-please-action@v4
id: release
with:
# TODO Configuring using manifest file as workaround until we move the frontend to its own repo
config-file: release-please.config.json
manifest-file: release-please.manifest.json
token: ${{ secrets.GITHUB_TOKEN }}

tag-frontend-release:
concurrency:
group: tag-frontend-release-${{ github.ref }}
cancel-in-progress: true

outputs:
tag: frontend-v${{ steps.extract-version.outputs.result }}

name: tag frontend release
runs-on: ubuntu-latest
if: ${{ (github.repository == 'chanzuckerberg/cryoet-data-portal') && (needs.create-frontend-release.outputs.prs_created == 'true') }}
needs: create-frontend-release
steps:
- name: merge release PR
uses: actions/github-script@v7
id: merge-release-pr
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const pr = ${{ needs.create-frontend-release.outputs.pr }}
console.log(`Merging release PR #${pr.number}`)
const [owner, repo] = '${{ github.repository }}'.split('/')
const [mergeResponse] = await Promise.all([
github.rest.pulls.merge({
owner,
repo,
pull_number: pr.number,
merge_method: 'squash',
}),
github.rest.issues.removeLabel({
owner,
repo,
issue_number: pr.number,
name: 'autorelease: pending'
}),
github.rest.issues.addLabels({
owner,
repo,
issue_number: pr.number,
labels: ['autorelease: tagged']
}),
])
return mergeResponse.data.sha
- name: checkout repo for tagging
uses: actions/checkout@v4
with:
ref: ${{ steps.merge-release-pr.outputs.result }}

- name: extract version
id: extract-version
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const pr = ${{ needs.create-frontend-release.outputs.pr }}
const version = pr.title.split(' ').at(-1)
return version
- name: tag release
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git tag -a frontend-v${{ steps.extract-version.outputs.result }} -m "Release frontend v${{ steps.extract-version.outputs.result }}"
git push origin frontend-v${{ steps.extract-version.outputs.result }}
run-staging-e2e-test:
name: Run e2e test on staging
Expand All @@ -27,7 +123,8 @@ jobs:
needs: run-staging-e2e-test
environment: prod
# The secret IS_DEPLOY_ALLOWED can be used to gate the prod deploys
if: ${{ github.repository == 'chanzuckerberg/cryoet-data-portal' && secrets.IS_DEPLOY_ALLOWED == 'true' }}
if: ${{ (github.repository == 'chanzuckerberg/cryoet-data-portal') && (secrets.IS_DEPLOY_ALLOWED == 'true') && (needs.create-frontend-release.outputs.prs_created == 'true') }}
needs: tag-frontend-release
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand Down
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "cryoet-data-portal",
"version": "1.0.0",
"scripts": {
"preinstall": "npx only-allow pnpm",
"build": "pnpm -r build",
Expand Down
22 changes: 22 additions & 0 deletions release-please.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"bootstrap-sha": "79825da91dd20c3be2f47912285e2c977848af32",
"skip-github-release": true,
"changelog-sections": [
{ "type": "feat", "section": "✨ Features" },
{ "type": "fix", "section": "🐞 Bug Fixes" },
{ "type": "perf", "section": "⚡️ Performance Improvements" },
{ "type": "revert", "section": "↩️ Reverts" },
{ "type": "docs", "section": "📝 Documentation" },
{ "type": "style", "section": "💅 Styles" },
{ "type": "chore", "section": "🧹 Miscellaneous Chores" },
{ "type": "refactor", "section": "♻️ Code Refactoring" },
{ "type": "test", "section": "🧪 Tests" },
{ "type": "build", "section": "🛠️ Build System" },
{ "type": "ci", "section": "⚙ Continuous Integration" }
],
"packages": {
"frontend": {
"release-type": "node"
}
}
}
3 changes: 3 additions & 0 deletions release-please.manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"frontend": "1.0.0"
}

0 comments on commit 4cb6a2f

Please sign in to comment.