From e4dbfe56438a040990e20668ecb64178f53caebb Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Sat, 17 Jul 2021 13:29:40 -0400 Subject: [PATCH] ci: deploys (#2) * ci: deploys * fix: indent --- .github/workflows/deploy.yml | 85 ++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..28358f4 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,85 @@ +on: + push: + branches: + master + pull_request: + +env: + NODE_VERSION: 16 + +jobs: + prepare: + runs-on: ubuntu-latest + name: Prepare + steps: + - uses: actions/checkout@v2 + - uses: actions/upload-artifact@v2 + with: + name: site + path: | + index.html + styles.css + hi.png + preview: + runs-on: ubuntu-latest + needs: prepare + name: Deploy preview + if: ${{ github.ref != 'refs/heads/master' }} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + id: node-setup + with: + node-version: ${{ env.NODE_VERSION }} + - name: Netlify CLI setup + run: npm install -g netlify-cli + - uses: actions/download-artifact@v2 + with: + name: site + path: dist + - name: Deploy + id: preview-deploy + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + run: | + netlify deploy --dir=dist > output.log + echo "::set-output name=draft-url::$(grep 'Website Draft URL' output.log)" + - name: Report + uses: actions/github-script@v2 + env: + DRAFT_URL: ${{ steps.preview-deploy.outputs.draft-url }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `:eyes: Branch deployed at ${process.env.DRAFT_URL}` + }) + deploy: + runs-on: ubuntu-latest + name: Deploy + needs: prepare + if: ${{ github.ref == 'refs/heads/master' }} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + id: node-setup + with: + node-version: ${{ env.NODE_VERSION }} + - name: Build Artifacts + uses: actions/download-artifact@v2 + with: + name: site + path: dist + - name: Netlify CLI setup + run: npm install -g netlify-cli + - name: Deploy + id: preview-deploy + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + run: | + netlify deploy --dir=dist --prod