summaryrefslogtreecommitdiff
path: root/docs/src/pages
diff options
context:
space:
mode:
authorGravatar Danny Burrows <44483126+danny-burrows@users.noreply.github.com> 2021-07-23 18:11:08 +0100
committerGravatar GitHub <noreply@github.com> 2021-07-23 10:11:08 -0700
commitb5fed3be9bc75bb7c5bda7ce793054ff674e3732 (patch)
tree5957341933ccc1d157e8d4c99eeeec7a5bd5da29 /docs/src/pages
parent599ad13e3161a4bbafad747d42479740f00df573 (diff)
downloadastro-b5fed3be9bc75bb7c5bda7ce793054ff674e3732.tar.gz
astro-b5fed3be9bc75bb7c5bda7ce793054ff674e3732.tar.zst
astro-b5fed3be9bc75bb7c5bda7ce793054ff674e3732.zip
📘 DOC: Adding github actions example to deploy.md (#823)
* Adding github actions example to deploy.md * Update wording and example Made the suggested changes * Apply suggestions from code review Co-authored-by: Caleb Jasik <calebjasik@jasik.xyz> Co-authored-by: Fred K. Schott <fkschott@gmail.com> Co-authored-by: Caleb Jasik <calebjasik@jasik.xyz> Co-authored-by: Fred K. Schott <fkschott@gmail.com>
Diffstat (limited to 'docs/src/pages')
-rw-r--r--docs/src/pages/guides/deploy.md60
1 files changed, 59 insertions, 1 deletions
diff --git a/docs/src/pages/guides/deploy.md b/docs/src/pages/guides/deploy.md
index 55c1b3aa8..d8e3dcbbb 100644
--- a/docs/src/pages/guides/deploy.md
+++ b/docs/src/pages/guides/deploy.md
@@ -68,7 +68,65 @@ By default, the build output will be placed at `dist/`. You may deploy this `dis
### GitHub Actions
-TODO: We'd love an example action snippet to share here!
+1. Set the correct `buildOptions.site` in `astro.config.mjs`
+2. Create the file `.github/workflows/main.yml` and add in the yaml below. Make sure to edit in your own details.
+3. In Github go to Settings > Developer settings > Personal Access tokens. Generate a new token with repo permissions.
+4. In the astro project repo (not \<YOUR USERNAME\>.github.io) go to Settings > Secrets and add your new personal access token with the name `API_TOKEN_GITHUB`.
+5. When you push changes to the astro project repo CI will deploy them to \<YOUR USERNAME\>.github.io for you.
+
+```yaml
+# Workflow to build and deploy to your Github Pages repo.
+
+# Edit your project details here.
+# Remember to add API_TOKEN_GITHUB in repo Settings > Secrets as well!
+env:
+ githubEmail: <YOUR GITHUB EMAIL ADDRESS>
+ deployToRepo: <NAME OF REPO TO DEPLOY TO (E.G. <YOUR USERNAME>.github.io)>
+
+name: Github Pages Astro CI
+
+on:
+ # Triggers the workflow on push and pull request events but only for the main branch
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+
+ # Allows you to run this workflow manually from the Actions tab.
+ workflow_dispatch:
+
+jobs:
+
+ deploy:
+ runs-on: ubuntu-latest
+
+ steps:
+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
+ - uses: actions/checkout@v2
+
+ # Install dependencies with npm
+ - name: Install dependencies
+ run: npm ci
+
+ # Build the project and add .nojekyll file to supress default behaviour
+ - name: Build
+ run: |
+ npm run build
+ touch ./dist/.nojekyll
+
+ # Push to your pages repo
+ - name: Push to pages repo
+ uses: cpina/github-action-push-to-another-repository@main
+ env:
+ API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
+ with:
+ source-directory: 'dist'
+ destination-github-username: ${{ github.actor }}
+ destination-repository-name: ${{ env.deployToRepo }}
+ user-email: ${{ env.githubEmail }}
+ commit-message: Deploy ORIGIN_COMMIT
+ target-branch: main
+```
### Travis CI