Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update netlify config and DOCS #174

Merged
merged 6 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/netlifypreview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ jobs:
uses: nwtgck/[email protected]
with:
publish-dir: './book/_build/html'
production-deploy: false
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
enable-github-deployment: false
enable-commit-status: false
enable-commit-comment: false
enable-pull-request-comment: true
overwrites-pull-request-comment: true
Expand Down
3 changes: 3 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This folder contains documentation on configuring a website based on this template

Some template feature require additional GitHub settings. For example, the `netlifypreview.yaml` workflow requires a [netlify account](https://www.netlify.com) and configuring Netlify and GitHub to work together
27 changes: 27 additions & 0 deletions docs/github-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# GitHub Setup

## GitHub Organization

We recommend that each hackweek creates a [GitHub Organization](https://docs.github.com/en/organizations/collaborating-with-groups-in-organizations/about-organizations ) to manage various repositories for an event. This makes organizing teams of users easy and consolidates content such as project work and tutorials for easier discoverability. It also allows managing secrets and making them available to different repositories if necessary.

## Hackweek Bots

For NASA-focused hackweeks we created a “bot” user with a gmail account, GitHub Account https://github.com/hackweek-admin, and NASA Earthdata login (https://urs.earthdata.nasa.gov ) to allow GitHub Actions workflows to access NASA Data with a set of credentials that do not belong to any individual.
scottyhq marked this conversation as resolved.
Show resolved Hide resolved

## GitHub Secrets

We can add credentials as [“Organization Secrets”]https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions ) and make them available to only select repositories that need them. For example see the screenshots below on giving the `EARTHDATA_PASS` secret to a specific repository
scottyhq marked this conversation as resolved.
Show resolved Hide resolved

1. Start by going to the `Settings` and `Secrets` for a specific repository the URL will look like this https://github.com/snowex-hackweek/website-2024/settings/secrets/actions
scottyhq marked this conversation as resolved.
Show resolved Hide resolved

**only people with `admin` access to the repository can access these settings**

![Repo secrets](./images/github-repo-secrets.png)

1. Select 'Manage organization secrets'. You can either create a new one, or click the "pencil" icon of an existing one to give access to a new repository

![Org Secrets](./images/github-org-secrets-list.png)

1. In the end, a website repository needs to have access to both `NETLIFY_AUTH_TOKEN` and a specific `NETLIFY_SITE_ID` for the preview workflow to function:
scottyhq marked this conversation as resolved.
Show resolved Hide resolved

![Repo secrets final](./images/github-repo-secrets2.png)
scottyhq marked this conversation as resolved.
Show resolved Hide resolved
scottyhq marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/github-org-secrets-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/github-repo-secrets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/github-repo-secrets2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/netlify-addsite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/netlify-auth-token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/netlify-install-github-app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/netlify-link-github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/netlify-repo-access.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/netlify-select-org.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/netlify-select-repo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions docs/netlify-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Configuing netlify for pull request previews

Check failure on line 1 in docs/netlify-setup.md

View workflow job for this annotation

GitHub Actions / quality-control

Configuing ==> Configuring
jomey marked this conversation as resolved.
Show resolved Hide resolved

Public websites for hackweeks have content contributed by many different people, and we want to ensure that they are well-formatted and functional at all times. In order to do this, we ‘preview’ changes to a website to confirm it all looks good before merging new content. There are different ways to accomplish this, but we have found that Netlify is free and works well for public sites.

## Link netlify to a repository

Netlify organizes websites by 'Site' which is tied to a specific GitHub repository. All preview links created are persistent but not indexed by search engines. If you want to delete them, you can delete the 'Site' from Netlify. Importantly, the Netlify previews are completely decoupled from the main website that is hosted by GitHub pages, so you do not need to worry about overwriting or losing your main event webpage!

1. Make sure the Netlify App is installed for your organization

https://github.com/apps/netlify/installations/select_target

Or visit GitHub Org settings for GitHub Apps (e.g. https://github.com/organizations/snowex-hackweek/settings/installations)

![Add Site](./images/netlify-install-github-app.png)

Under 'Configure' for Netlify you can select which repositories Netlify has access to.

![Add Site](./images/netlify-repo-access.png)

1. Log into netlify and 'Add new site'

![Add Site](./images/netlify-addsite.png)

1. Select deploy project with GitHub

![Link GitHub](./images/netlify-link-github.png)

1. Select correct GitHub Organization for website repo

![Select org](./images/netlify-select-org.png)

1. Select correct repository based on this template (e.g. website-2024)

![Select repo](./images/netlify-select-repo.png)

For 'Site name' enter something informative like `snowex-website-2024` and click 'Deploy'

1. Disable netlify main deployment

Important!! We only want to use Netlify for *Previews* so under 'Site Configuration' -> 'Build & Deploy' -> 'Continuous deployment' -> 'Build settings' select "Stopped Builds"
(e.g. https://app.netlify.com/sites/snowex-website-2024/configuration/deploys)

If you do not do this, you will have a public mirror of your website available at your netlify site name (https://snowex-website-2024.netlify.app)

![Disable builds](./images/netlify-stop-builds.png)
scottyhq marked this conversation as resolved.
Show resolved Hide resolved

1. Copy unique NETLIFY_SITE_ID to use in GitHub Actions Workflows

Copy the "Site ID" token string under "Site Details", it will look something like this "f9235abc-688d-45e4-8f62-5519ghi455j1"

(e.g. https://app.netlify.com/sites/snowex-website-2024/configuration/general)

1. Finally, create a NETLIFY_AUTH_TOKEN to use in GitHub Actions workflows

Go to https://app.netlify.com/user/applications and under 'Personal access token' create a new token with optional expiration. It will look something like this `nfp_8abcUxd2ESPs9yEegb3ATSBst13JicvY135s`

![Auth token](./images/netlify-auth-token.png)
Loading