chore: add write-all permission #119
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: | |
push: | |
branches: [main, develop] | |
concurrency: | |
group: ${{ github.ref }} | |
permissions: write-all | |
jobs: | |
lint-and-test: | |
name: Lint and unit test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout ${{ github.ref }} branch | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
- uses: pnpm/[email protected] | |
with: | |
version: 7.0.1 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: 16.15.0 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Set environment variables | |
run: echo ${{ secrets.TEST_APP_ENV }} | openssl base64 -d -A -out .env | |
- name: Run lint and type checks | |
run: | | |
pnpm concurrently -g \ | |
"pnpm lint" \ | |
"pnpm check:types" | |
deploy-to-dev: | |
name: Deploy App to Dev | |
if: github.event.ref == 'refs/heads/develop' | |
needs: lint-and-test | |
uses: ./.github/workflows/deploy-action.yml | |
with: | |
environment: dev | |
branch: ${{ github.ref }} | |
secrets: | |
app_env: ${{ secrets.APP_ENV }} | |
vercel_token: ${{ secrets.VERCEL_TOKEN }} | |
org_id: ${{ secrets.VERCEL_ORG_ID }} | |
project_id: ${{ secrets.VERCEL_PROJECT_ID }} | |
release: | |
name: Release | |
if: github.event.ref == 'refs/heads/main' | |
needs: lint-and-test | |
runs-on: ubuntu-latest | |
outputs: | |
skipped: ${{ steps.changelog.outputs.skipped }} | |
tag: ${{ steps.changelog.outputs.tag }} | |
steps: | |
- name: Checkout main branch | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
token: ${{ secrets.PAT }} | |
- id: changelog | |
name: Conventional Changelog | |
uses: TriPSs/conventional-changelog-action@v3 | |
with: | |
git-message: 'chore(release): {version} [no ci]' | |
git-user-email: [email protected] | |
git-user-name: Emmanuel Nipal | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
output-file: 'false' | |
- name: Create Github Release | |
uses: actions/create-release@v1 | |
if: ${{ steps.changelog.outputs.skipped == 'false' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.changelog.outputs.tag }} | |
release_name: ${{ steps.changelog.outputs.tag }} | |
body: ${{ steps.changelog.outputs.clean_changelog }} | |
deploy-to-production: | |
name: Deploy App to Production | |
if: needs.release.outputs.skipped == 'false' | |
needs: release | |
uses: ./.github/workflows/deploy-action.yml | |
with: | |
environment: production | |
branch: 'refs/tags/${{needs.release.outputs.tag}}' | |
secrets: | |
app_env: ${{ secrets.APP_ENV }} | |
vercel_token: ${{ secrets.VERCEL_TOKEN }} | |
org_id: ${{ secrets.VERCEL_ORG_ID }} | |
project_id: ${{ secrets.VERCEL_PROJECT_ID }} |