-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move website deploy from Travis to GH Actions (#887)
* Moves all GH publish steps out of the publish script, and updates the built directory structure to better mirror the final output. * Since this script is now safe to run locally, rename to `build.sh` and update the npm script to use this directly. * Add actions-gh-pages to the github actions workflow, renaming to CI. * Removes references to Travis CI. See also: https://twitter.com/peter_szilagyi/status/1437646118700175360
- Loading branch information
Showing
7 changed files
with
150 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '16.x' | ||
- run: npm ci | ||
- run: npm test | ||
publish: | ||
if: github.ref == 'refs/heads/main' | ||
needs: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '16.x' | ||
- run: npm ci | ||
- run: npm run build | ||
- uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
keep_files: true | ||
cname: spec.graphql.org | ||
user_name: 'github-actions[bot]' | ||
user_email: 'github-actions[bot]@users.noreply.github.com' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,6 @@ | |
.DS_Store | ||
npm-debug.log | ||
/build | ||
/out | ||
/public | ||
/gh-pages | ||
/node_modules |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,30 +4,16 @@ | |
# Determine if this is a tagged release | ||
GITTAG=$(git tag --points-at HEAD) | ||
|
||
# Build the specification document into publishable form | ||
echo "Building spec" | ||
mkdir -p out | ||
if [ -n "$GITTAG" ]; then | ||
spec-md --githubSource "https://github.com/graphql/graphql-spec/blame/$GITTAG/" spec/GraphQL.md > out/index.html | ||
else | ||
spec-md --githubSource "https://github.com/graphql/graphql-spec/blame/main/" spec/GraphQL.md > out/index.html | ||
fi | ||
npm run build > /dev/null 2>&1 | ||
|
||
# Check out gh-pages locally. | ||
echo "Cloning gh-pages" | ||
rm -rf gh-pages | ||
git clone -b gh-pages "https://${GH_TOKEN}@github.com/graphql/graphql-spec.git" gh-pages > /dev/null 2>&1 | ||
# Build the specification draft document | ||
echo "Building spec draft" | ||
mkdir -p public/draft | ||
spec-md --githubSource "https://github.com/graphql/graphql-spec/blame/main/" spec/GraphQL.md > public/draft/index.html | ||
|
||
# Replace /draft with this build. | ||
echo "Publishing to: /draft" | ||
rm -rf gh-pages/draft | ||
cp -R out/ gh-pages/draft | ||
|
||
# If this is a tagged commit, publish to a permalink and index. | ||
# If this is a tagged commit, also build the release document | ||
if [ -n "$GITTAG" ]; then | ||
echo "Publishing to: /$GITTAG" | ||
cp -R out/ "gh-pages/$GITTAG" | ||
echo "Building spec release $GITTAG" | ||
mkdir -p "public/$GITTAG" | ||
spec-md --githubSource "https://github.com/graphql/graphql-spec/blame/$GITTAG/" spec/GraphQL.md > "public/$GITTAG/index.html" | ||
fi | ||
|
||
# Create the index file | ||
|
@@ -116,17 +102,4 @@ HTML="$HTML | |
</body> | ||
</html>" | ||
|
||
echo $HTML > "gh-pages/index.html" | ||
|
||
echo "Pushing update" | ||
cd gh-pages | ||
git config user.name "Travis CI" | ||
git config user.email "[email protected]" | ||
git add -A . | ||
if git diff --staged --quiet; then | ||
echo "Nothing to publish" | ||
else | ||
git commit -a -m "Deploy to GitHub Pages" | ||
git push > /dev/null 2>&1 | ||
echo "Pushed" | ||
fi | ||
echo $HTML > "public/index.html" |
Oops, something went wrong.