diff --git a/.github/workflows/build-and-deploy-site.yml b/.github/workflows/build-and-deploy-site.yml new file mode 100644 index 000000000..76ace81fb --- /dev/null +++ b/.github/workflows/build-and-deploy-site.yml @@ -0,0 +1,28 @@ +name: Build and Deploy Site +on: + push: + branches: [ master ] + paths: + - '!**' + - 'site/**' +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@master + with: + fetch-depth: 1 + + - name: Install and Build 🔧 + run: | + cd site + npm install + npm run build + + - name: Deploy 🚀 + uses: JamesIves/github-pages-deploy-action@4.0.0 + with: + branch: site # The branch the action should deploy to. + folder: public # The folder the action should deploy. + clean: true diff --git a/.github/workflows/build-and-preview-site.yml b/.github/workflows/build-and-preview-site.yml new file mode 100644 index 000000000..f818fe941 --- /dev/null +++ b/.github/workflows/build-and-preview-site.yml @@ -0,0 +1,34 @@ +name: Build and Preview Site +on: + pull_request: + branches: [ master ] + types: [opened, synchronize, reopened] + paths: + - '!**' + - 'site/**' + +jobs: + site-preview: + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@master + with: + persist-credentials: false + fetch-depth: 1 + + - name: Install and Build 🔧 + run: | + cd site + npm install + npm run noIndex + - name: Zip Site + run: bash site/script.sh + - name: Upload files + uses: actions/upload-artifact@master + with: + name: public-dir + path: ./public-dir.zip + retention-days: 1 + - name: Triger Inner workflow + run: echo "trigering inner workflow" diff --git a/.github/workflows/preview-site.yml b/.github/workflows/preview-site.yml new file mode 100644 index 000000000..c784607ea --- /dev/null +++ b/.github/workflows/preview-site.yml @@ -0,0 +1,46 @@ +name: Deploy Preview +on: + workflow_run: + workflows: + - Build and Preview Site + types: + - completed + +jobs: + deploy-preview: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2.3.1 + + - name: Download Site dir + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{ secrets.GH_ACCESS_TOKEN }} + workflow: build-and-preview-site.yml + run_id: ${{ github.event.workflow_run.id }} + name: public-dir + + - name: Unzip Site + run: | + rm -rf ./site/public + unzip public-dir.zip + rm -f public-dir.zip + + - name: Deploy to Netlify + id: netlify + uses: nwtgck/actions-netlify@v1.1 + with: + publish-dir: 'site/public' + production-deploy: false + github-token: ${{ secrets.GH_ACCESS_TOKEN }} + enable-commit-comment: false + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + + - name: Comment Deploy URL + uses: ./.github/actions/comment-preview-on-pr + with: + token: ${{ secrets.GH_ACCESS_TOKEN }} + deploy_url: "${{ steps.netlify.outputs.deploy-url }}" \ No newline at end of file