Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add no deploy label + misc actions stuff #423

Merged
merged 13 commits into from
Feb 15, 2024
20 changes: 9 additions & 11 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,29 @@ jobs:
build_and_deploy:
name: Build and deploy PeterPortal
runs-on: ubuntu-latest
if: (github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'no deploy'))
environment:
name: ${{ (github.event_name == 'pull_request' && format('staging-{0}', github.event.pull_request.number)) || 'production' }}
url: https://${{ (github.event_name == 'pull_request' && format('staging-{0}.peterportal.org', github.event.pull_request.number)) || 'peterportal.org' }}

concurrency:
group: build-${{ github.head_ref || github.run_id }}
group: build-and-deploy-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

steps:
- name: Check Out Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install Dependencies
run: npm install
env:
HUSKY: 0

- name: Build and deploy
run: npx sst deploy --stage ${{ (github.event_name == 'pull_request' && format('staging-{0}', github.event.pull_request.number)) || 'prod' }}
Expand All @@ -46,11 +52,3 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
NODE_ENV: ${{ github.event_name == 'pull_request' && 'staging' || 'production' }}

- name: Comment staging URL
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ github.event_name == 'pull_request' }}
with:
header: staging url
recreate: true
message: Deployed staging instance to https://staging-${{ github.event.pull_request.number }}.peterportal.org
15 changes: 12 additions & 3 deletions .github/workflows/clean-up-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- master

concurrency:
group: deploy-${{ github.head_ref || github.run_id }}
group: clean-up-pr-${{ github.head_ref || github.run_id }}

jobs:
clean-up-pr:
Expand All @@ -18,16 +18,18 @@ jobs:

steps:
- name: Check Out Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install Dependencies
run: npm install
env:
HUSKY: 0

- name: Remove staging stack
run: npx sst remove --stage ${{ format('staging-{0}', github.event.pull_request.number) }} backend && npx sst remove --stage ${{ format('staging-{0}', github.event.pull_request.number) }} frontend
Expand All @@ -44,3 +46,10 @@ jobs:
PRODUCTION_DOMAIN: ${{secrets.PRODUCTION_DOMAIN}}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Deactivate deployment
uses: strumwolf/[email protected]
with:
environment: ${{ format('staging-{0}', github.event.pull_request.number) }}
token: ${{ secrets.GITHUB_TOKEN }}
onlyDeactivateDeployments: true
6 changes: 4 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ jobs:

steps:
- name: Check Out Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install Dependencies
run: npm install
env:
HUSKY: 0

- name: Lint
run: npm run lint
Loading