From b27ea6b86049e3487ba0bd4ccde32be7e4c5e597 Mon Sep 17 00:00:00 2001 From: coltborg Date: Sat, 8 Jun 2024 11:51:37 -0500 Subject: [PATCH] Use GitHub Action for deploy --- .github/workflows/deploy-to-github-pages.yml | 44 ++++++++++++++++++++ .gitignore | 1 + package.json | 3 +- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy-to-github-pages.yml diff --git a/.github/workflows/deploy-to-github-pages.yml b/.github/workflows/deploy-to-github-pages.yml new file mode 100644 index 0000000..b95fa44 --- /dev/null +++ b/.github/workflows/deploy-to-github-pages.yml @@ -0,0 +1,44 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: + - main + pull_request: + +jobs: + deploy: + runs-on: ubuntu-22.04 + permissions: + contents: write + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + steps: + - uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: "18" + + - name: Persist npm cache + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }} + + - name: Persist Eleventy .cache + uses: actions/cache@v3 + with: + path: ./.cache + key: ${{ runner.os }}-eleventy-fetch-cache + + - run: npm install + - run: npm run build + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + if: github.ref == 'refs/heads/main' + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./_site diff --git a/.gitignore b/.gitignore index e172a8e..17fe88a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ _drafts/ _site/ +.cache diff --git a/package.json b/package.json index 78365a7..88ef031 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "install": "npx install", - "serve": "npx @11ty/eleventy --serve" + "serve": "npx @11ty/eleventy --serve", + "build": "npx @11ty/eleventy" }, "author": "", "license": "ISC",