2020-12-02 20:48:03 +00:00
name : Deploy Fleet website
on :
push :
2021-06-10 19:22:31 +00:00
branches : [ main ]
2021-11-18 23:14:29 +00:00
paths :
- 'website/**'
- 'docs/**'
- 'handbook/**'
2020-12-02 20:48:03 +00:00
jobs :
build :
2020-12-04 21:49:22 +00:00
if : ${{ github.repository == 'fleetdm/fleet' }}
2021-05-10 04:48:59 +00:00
2020-12-04 17:52:47 +00:00
runs-on : ubuntu-latest
2020-12-02 20:48:03 +00:00
2020-12-04 20:20:57 +00:00
strategy :
matrix :
node-version : [ 14. x]
2020-12-02 20:48:03 +00:00
2020-12-04 20:20:57 +00:00
steps :
- uses : actions/checkout@v2
2020-12-02 20:48:03 +00:00
2020-12-04 20:20:57 +00:00
# Configure our access credentials for the Heroku CLI
- uses : akhileshns/heroku-deploy@v3.6.8
with :
heroku_api_key : ${{secrets.HEROKU_API_TOKEN_FOR_BOT_USER}}
heroku_app_name : "" # this has to be blank or it doesn't work
heroku_email : ${{secrets.HEROKU_EMAIL_FOR_BOT_USER}}
justlogin : true
- run : heroku auth:whoami
2020-12-02 20:48:03 +00:00
2020-12-04 20:20:57 +00:00
# Set the Node.js version
- name : Use Node.js ${{ matrix.node-version }}
uses : actions/setup-node@v1
with :
node-version : ${{ matrix.node-version }}
2020-12-02 20:48:03 +00:00
2020-12-04 20:20:57 +00:00
# Now start building!
# > …but first, get a little crazy for a sec and delete the top-level package.json file
# > i.e. the one used by the Fleet server. This is because require() in node will go
# > hunting in ancestral directories for missing dependencies, and since some of the
# > bundled transpiler tasks sniff for package availability using require(), this trips
# > up when it encounters another Node universe in the parent directory.
- run : rm -rf package.json package-lock.json node_modules/
# > Turns out there's a similar issue with how eslint plugins are looked up, so we
# > delete the top level .eslintrc file too.
- run : rm -f .eslintrc.js
2020-12-02 20:48:03 +00:00
2021-05-20 08:22:42 +00:00
# Download dependencies (including dev deps)
2020-12-04 20:20:57 +00:00
- run : cd website/ && npm install
2020-12-02 20:48:03 +00:00
2020-12-04 20:20:57 +00:00
# Run sanity checks
- run : cd website/ && npm test
2020-12-02 20:48:03 +00:00
2021-05-10 04:48:59 +00:00
# Compile browser assets & markdown content into generated collateral
2020-12-04 20:20:57 +00:00
- run : cd website/ && npm run build-for-prod
2020-12-02 20:48:03 +00:00
2021-05-10 04:48:59 +00:00
# Commit newly-generated collateral locally so we can push them to Heroku below.
2020-12-04 20:20:57 +00:00
# (This commit will never be pushed to GitHub- only to Heroku.)
# > The local config flags make this work in GitHub's environment.
- run : git add website/.www
2021-08-18 01:08:25 +00:00
- run : git add -f website/views/partials/built-from-markdown > /dev/null 2>&1 || echo '* * * WARNING - Silently ignoring the fact that there are no HTML partials generated from markdown to include in automated commit...'
2021-05-10 04:48:59 +00:00
- run : git -c "user.name=Fleetwood" -c "user.email=github@example.com" commit -am 'AUTOMATED COMMIT - Deployed the latest, including generated collateral such as compiled documentation, modified HTML layouts, and a .sailsrc file that references minified client-side code assets.'
2020-12-02 20:48:03 +00:00
2020-12-04 20:20:57 +00:00
# Configure the Heroku app we'll be deploying to
- run : heroku git:remote -a production-fleetdm-website
- run : git remote -v
2020-12-02 20:48:03 +00:00
2020-12-04 20:20:57 +00:00
# Deploy to Heroku (by pushing)
# > Since a shallow clone was grabbed, we have to "unshallow" it before forcepushing.
- run : echo "Unshallowing local repository…"
- run : git fetch --prune --unshallow
- run : echo "Deploying branch '${GITHUB_REF##*/}' to Heroku…"
2021-06-10 19:22:31 +00:00
- run : git push heroku +${GITHUB_REF##*/}:master # note that Heroku, at least as of Jun 10 2021, still uses "master" on their end
2020-12-04 20:20:57 +00:00
- name : 🌐 https://fleetdm.com
run : echo '' && echo '--' && echo 'OK, done. It should be live momentarily.' && echo '(if you get impatient, check the Heroku dashboard for status)' && echo && echo ' 🌐–• https://fleetdm.com'