diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index e7648d94..6997bfd4 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -16,16 +16,6 @@ jobs: if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }} runs-on: ubuntu-latest steps: - - name: Big Eye-catching Banner - run: | - echo "::warning::" - echo "******************************************************************************" - echo "* *" - echo "* 🚀 Running Preview Workflow boiiiiii 🚀 *" - echo "* *" - echo "******************************************************************************" - echo "::end::" - - uses: actions/checkout@v4 - name: Download build artifacts @@ -36,22 +26,9 @@ jobs: run-id: ${{ github.event.workflow_run.id }} github-token: ${{ secrets.GITHUB_TOKEN }} - - name: List dist directory contents - run: ls -R ./dist - - - name: Check if AccountMenu.jsx exists - run: | - if [ ! -f ./dist/src/components/AppHeader/AccountMenu.jsx ]; then - echo "::error:: AccountMenu.jsx not found!" - exit 1 - fi - - name: Get Git Commit Hash id: commit_hash - run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV - - - name: Inject Git Commit Hash - run: sed -i "s/REACT_APP_GIT_COMMIT_HASH_PLACEHOLDER/${{ env.COMMIT_HASH }}/g" ./dist/src/components/AppHeader/AccountMenu.jsx + run: echo "::set-output name=commit_hash::$(git rev-parse HEAD)" - name: Find PR number id: pr @@ -71,14 +48,17 @@ jobs: console.info("Pull request number is", pullRequestNumber) return pullRequestNumber - - name: Build Project - run: npm run build + - name: Inject Git Commit Hash + run: sed -i "s/REACT_APP_GIT_COMMIT_HASH/${{ steps.commit_hash.outputs.commit_hash }}/g" ./src/components/AppHeader/AccountMenu.jsx + - name: Set React Environment Variable + run: echo "REACT_APP_GIT_COMMIT_HASH=${{ steps.commit_hash.outputs.commit_hash }}" >> $GITHUB_ENV +fix - name: Deploy to Cloudflare Pages id: cloudflare-publish uses: cloudflare/pages-action@v1.5.0 with: - branch: ${{ github.head_ref }} + branch: ${{ steps.pr.outputs.result }} projectName: connect accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }} @@ -94,7 +74,7 @@ jobs: * mark your PR as a draft until it's ready to review * post the preview on [Discord](https://discord.comma.ai); feedback from users will speed up the PR review - Deployed preview: https://${{ steps.pr.outputs.result }}.connect-d5y.pages.dev (Commit: ${{ env.COMMIT_HASH }}) + Deployed preview: https://${{ steps.pr.outputs.result }}.connect-d5y.pages.dev (Commit: ${{ steps.commit_hash.outputs.commit_hash }}) comment_tag: run_id pr_number: ${{ steps.pr.outputs.result }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}