diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c3255261..eb070c5f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,9 +12,14 @@ on: jobs: build: runs-on: ubuntu-latest + outputs: + artifact_name: ${{ steps.set_artifact_name.outputs.name }} steps: - name: Set current date as env variable - run: echo "DATE_NOW=$(date +'%Y-%m-%dT%H-%M-%S')" >> $GITHUB_ENV + id: set_artifact_name + run: | + echo "DATE_NOW=$(date +'%Y-%m-%dT%H-%M-%S')" >> $GITHUB_ENV + echo "name=dist-$(date +'%Y-%m-%dT%H-%M-%S')" >> $GITHUB_OUTPUT - name: Checkout uses: actions/checkout@v3 with: @@ -58,3 +63,26 @@ jobs: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 + + preview: + needs: build + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ${{ needs.build.outputs.artifact_name }} + path: ./dist + - name: Deploy to Netlify + uses: nwtgck/actions-netlify@v2.0 + with: + publish-dir: './dist' + production-branch: main + github-token: ${{ secrets.GITHUB_TOKEN }} + deploy-message: "Deploy Preview for PR #${{ github.event.number }}" + enable-pull-request-comment: true + enable-commit-comment: true + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} diff --git a/README.md b/README.md index 77c9d13d..3b15dec3 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,5 @@ npm start ``` See [github workflow](.github/workflows/deploy.yml) and [package.json](package.json) for more information. + +TEST PR