mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +01:00
ci: github actions (#3442)
* feat: eslint action * refactor: actions v2 * fix: set +x for entrypoint * ci: integrate docs * fix: give it a nice name * ci: publish docs * ci: fix yaml key error * ci: fix executable * ci: use normal sh shebang * ci: move into the workspace * ci: fix eslint path * ci: manually run the build * ci: use different container * ci: install git * ci: assume yes flag * ci: use correct branch * ci: fix branch and source * ci: fix condition * ci: remove useless steps * ci: rename action * ci: make executable again * ci: cleanup * ci: add stable branch * ci: remove semi * ci: do some logging for failing action * ci: remove actions api * ci: re-add semi * ci: use actions repo * ci: use v1 tags * ci: remove semi * chore: change job name passed to eslint * chore: dummy commit, remove different semi * ci: change job name * chore: dummy commit * ci: add gh-actions as possible branches * ci: lint all branches * ci: dummy * ci: separate pr and push * chore: run actions on gh branch * ci: try excluding branches
This commit is contained in:
11
.github/actions/docs/Dockerfile
vendored
Normal file
11
.github/actions/docs/Dockerfile
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
FROM node:12-slim
|
||||||
|
|
||||||
|
LABEL com.github.actions.name="Docs"
|
||||||
|
LABEL com.github.actions.description="Commit docs to the docs/ branch."
|
||||||
|
LABEL com.github.actions.icon="upload-cloud"
|
||||||
|
LABEL com.github.actions.color="blue"
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y git
|
||||||
|
|
||||||
|
COPY src /actions/docs/src
|
||||||
|
ENTRYPOINT ["/actions/docs/src/entrypoint.sh"]
|
||||||
54
.github/actions/docs/src/entrypoint.sh
vendored
Executable file
54
.github/actions/docs/src/entrypoint.sh
vendored
Executable file
@@ -0,0 +1,54 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd $GITHUB_WORKSPACE
|
||||||
|
|
||||||
|
# Run the build
|
||||||
|
npm run docs
|
||||||
|
NODE_ENV=production npm run build:browser
|
||||||
|
|
||||||
|
# Initialise some useful variables
|
||||||
|
REPO="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
|
||||||
|
BRANCH_OR_TAG=`awk -F/ '{print $2}' <<< $GITHUB_REF`
|
||||||
|
CURRENT_BRANCH=`awk -F/ '{print $NF}' <<< $GITHUB_REF`
|
||||||
|
|
||||||
|
if [ "$BRANCH_OR_TAG" == "heads" ]; then
|
||||||
|
SOURCE_TYPE="branch"
|
||||||
|
else
|
||||||
|
SOURCE_TYPE="tag"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Checkout the repo in the target branch so we can build docs and push to it
|
||||||
|
TARGET_BRANCH="docs"
|
||||||
|
git clone $REPO out -b $TARGET_BRANCH
|
||||||
|
|
||||||
|
# Move the generated JSON file to the newly-checked-out repo, to be committed and pushed
|
||||||
|
mv docs/docs.json out/$CURRENT_BRANCH.json
|
||||||
|
|
||||||
|
# Commit and push
|
||||||
|
cd out
|
||||||
|
git add .
|
||||||
|
git config user.name "${GITHUB_ACTOR}"
|
||||||
|
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||||
|
git commit -m "Docs build for ${SOURCE_TYPE} ${CURRENT_BRANCH}: ${GITHUB_SHA}" || true
|
||||||
|
git push origin $TARGET_BRANCH
|
||||||
|
|
||||||
|
# Clean up...
|
||||||
|
cd ..
|
||||||
|
rm -rf out
|
||||||
|
|
||||||
|
# ...then do the same once more for the webpack
|
||||||
|
TARGET_BRANCH="webpack"
|
||||||
|
git clone $REPO out -b $TARGET_BRANCH
|
||||||
|
|
||||||
|
# Move the generated webpack over
|
||||||
|
mv webpack/discord.min.js out/discord.$CURRENT_BRANCH.min.js
|
||||||
|
|
||||||
|
# Commit and push
|
||||||
|
cd out
|
||||||
|
git add .
|
||||||
|
git config user.name "${GITHUB_ACTOR}"
|
||||||
|
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||||
|
git commit -m "Webpack build for ${SOURCE_TYPE} ${CURRENT_BRANCH}: ${GITHUB_SHA}" || true
|
||||||
|
git push origin $TARGET_BRANCH
|
||||||
25
.github/workflows/docs.yml
vendored
Normal file
25
.github/workflows/docs.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
name: Docs
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '!gh-action'
|
||||||
|
- '!webpack'
|
||||||
|
- '!docs'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docs:
|
||||||
|
name: deploy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@master
|
||||||
|
- name: install node v12
|
||||||
|
uses: actions/setup-node@master
|
||||||
|
with:
|
||||||
|
node-version: 12
|
||||||
|
- name: npm install
|
||||||
|
run: npm install
|
||||||
|
- name: deploy docs
|
||||||
|
uses: ./.github/actions/docs
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
28
.github/workflows/lint.yml
vendored
Normal file
28
.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
name: Lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: install node v12
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 12
|
||||||
|
- name: npm install
|
||||||
|
run: npm install
|
||||||
|
- name: eslint
|
||||||
|
uses: discordjs/action-eslint@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
job-name: lint
|
||||||
|
- name: lint typings
|
||||||
|
run: npm run lint:typings
|
||||||
|
- name: lint docs
|
||||||
|
run: npm run docs:test
|
||||||
@@ -20,4 +20,4 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Run the tests
|
# Run the tests
|
||||||
npm test
|
npm run docs:test && npm run lint:typings
|
||||||
|
|||||||
Reference in New Issue
Block a user