diff --git a/.github/workflows/preview-app-label.yml b/.github/workflows/preview-app-label.yml index 2139e4641..cf68ed948 100644 --- a/.github/workflows/preview-app-label.yml +++ b/.github/workflows/preview-app-label.yml @@ -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/vercel-action@v25.1.1 + - 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: