diff --git a/.github/workflows/build.yml b/.github/workflows/deploy.yml similarity index 70% rename from .github/workflows/build.yml rename to .github/workflows/deploy.yml index e78e3df..8186a28 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/deploy.yml @@ -8,6 +8,8 @@ on: - main env: BRANCH_NAME: ${{ github.ref_name }} +permissions: + pull-requests: write jobs: lint: runs-on: ubuntu-latest @@ -68,6 +70,8 @@ jobs: deploy: runs-on: ubuntu-latest needs: build + outputs: + NETLIFY_PREVIEW_URL: ${{ steps.url_preview.outputs.NETLIFY_PREVIEW_URL }} steps: - name: Get build artifacts uses: actions/download-artifact@v4 @@ -87,7 +91,15 @@ jobs: --dir dist \ --site ${{ secrets.NETLIFY_SITE_ID }} \ --auth ${{ secrets.NETLIFY_API_TOKEN }} \ - $prod_flag + $prod_flag \ + --json \ + > deploy_output.json + - name: Generate URL Preview + id: url_preview + if: ${{ env.BRANCH_NAME != 'main' }} + run: | + NETLIFY_PREVIEW_URL=$(jq -r '.deploy_url' deploy_output.json) + echo "NETLIFY_PREVIEW_URL=$NETLIFY_PREVIEW_URL" >> "$GITHUB_OUTPUT" report: runs-on: ubuntu-latest needs: [lint, build] @@ -97,3 +109,22 @@ jobs: run: | echo "Something went wrong!" echo "${{ toJson(github)}}" + preview_url: + runs-on: ubuntu-latest + needs: deploy + if: ${{ github.ref_name != 'main' }} + steps: + - name: Output URL + run: echo ${{ needs.deploy.outputs.NETLIFY_PREVIEW_URL }} + - name: Comment URL Preview on PR + uses: actions/github-script@v7 + env: + NETLIFY_PREVIEW_URL: ${{ needs.deploy.outputs.NETLIFY_PREVIEW_URL }} + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '🚀 Preview URL: ' + process.env.NETLIFY_PREVIEW_URL + }) diff --git a/.vscode/settings.json b/.vscode/settings.json index 71c165c..5f3b5f9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,7 +3,8 @@ "gitlens.codeLens.recentChange.enabled": false, "gitlens.codeLens.authors.enabled": false, "material-icon-theme.files.associations": { - ".tool-versions": "nodejs_alt" + ".tool-versions": "nodejs_alt", + "_redirects": "netlify" }, "material-icon-theme.folders.associations": { "actions": "gh-workflows", diff --git a/public/_redirects b/public/_redirects new file mode 100644 index 0000000..7797f7c --- /dev/null +++ b/public/_redirects @@ -0,0 +1 @@ +/* /index.html 200