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

Move website deploy from Travis to GH Actions #887

Merged
merged 1 commit into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
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'
12 changes: 0 additions & 12 deletions .github/workflows/test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
.DS_Store
npm-debug.log
/build
/out
/public
/gh-pages
/node_modules
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

45 changes: 9 additions & 36 deletions publish.sh → build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 "github@fb.com"
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"
Loading