-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
42 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,39 @@ | ||
name: Vercel preview apps on label | ||
|
||
env: | ||
VERCEL_ACCESS_TOKEN: ${{ secrets.VERCEL_ACCESS_TOKEN }} | ||
VERCEL_PROJECT_ID: ${{ secrets.PROJECT_ID }} | ||
|
||
on: | ||
pull_request: | ||
types: [labeled] | ||
jobs: | ||
build: | ||
name: Build | ||
deploy: | ||
if: ${{ github.event.label.name == 'create preview app' }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
steps: | ||
- name: Branch name | ||
run: echo running on branch ${GITHUB_REF##*/} | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
- uses: snaplet/vercel-action@v3 | ||
- name: Remove label | ||
uses: fastruby/pr-unlabeler@v1 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT | ||
|
||
- name: Build | ||
label-to-remove: "create-preview-app" | ||
env: | ||
NODE_OPTIONS: "--openssl-legacy-provider" | ||
run: | | ||
yarn --frozen-lockfile --prefer-offline | ||
./node_modules/.bin/ember build --output-path="test_build" --environment=development | ||
deploy: | ||
if: ${{ github.event.label.name == 'create preview app' }} | ||
needs: build | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
delete: | ||
if: ${{ github.event.label.name == 'destroy preview app' }} | ||
runs-on: ubuntu-latest | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Extract variables | ||
shell: bash | ||
run: | | ||
echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')" >> $GITHUB_OUTPUT | ||
echo "GIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | ||
echo "GIT_SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
id: extract_variables | ||
|
||
- name: Vercel deploy | ||
uses: amondnet/[email protected] | ||
- uses: actions/checkout@v3 | ||
- uses: snaplet/vercel-action@v3 | ||
with: | ||
vercel-token: ${{ secrets.VERCEL_TOKEN }} | ||
vercel-org-id: ${{ secrets.ORG_ID}} | ||
vercel-project-id: ${{ secrets.PROJECT_ID}} | ||
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--force' || '' }} | ||
scope: ${{ secrets.TEAM_ID}} | ||
vercel-project-name: 'bracco' | ||
- name: Remove label | ||
uses: fastruby/pr-unlabeler@v1 | ||
delete: true | ||
- uses: fastruby/pr-unlabeler@v1 | ||
with: | ||
label-to-remove: "create preview app" | ||
env: | ||
|