mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
Related to: https://github.com/fleetdm/fleet/issues/40309 Changes: - Added two workflows to test changes and deploy the ee/fleet-agent-downloader app on Heroku. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
105 lines
4.4 KiB
YAML
105 lines
4.4 KiB
YAML
name: Deploy Fleet agent downloader app to Heroku.
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
paths:
|
|
- 'ee/fleet-agent-downloader/**'
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
build:
|
|
permissions:
|
|
contents: read
|
|
if: ${{ github.repository == 'fleetdm/fleet' }}
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
strategy:
|
|
matrix:
|
|
node-version: [20.x]
|
|
|
|
steps:
|
|
- name: Harden Runner
|
|
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
|
with:
|
|
egress-policy: audit
|
|
|
|
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
|
|
|
# Configure our access credentials for the Heroku CLI
|
|
- uses: akhileshns/heroku-deploy@e3eb99d45a8e2ec5dca08735e089607befa4bf28 # v3.14.15
|
|
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
|
|
# Install the heroku-repo plugin in the Heroku CLI
|
|
- run: heroku plugins:install heroku-repo
|
|
|
|
# Set the Node.js version
|
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
|
|
# 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
|
|
# > And, as a change to the top-level fleetdm/fleet .gitignore on May 2, 2022 revealed,
|
|
# > we also need to delete the top level .gitignore file too, so that its rules don't
|
|
# > interfere with the committing and force-pushing we're doing as part of our deploy
|
|
# > script here. For more info, see: https://github.com/fleetdm/fleet/pull/5549
|
|
- run: rm -f .gitignore
|
|
|
|
# Get dependencies (including dev deps)
|
|
- run: cd ee/fleet-agent-downloader/ && npm install
|
|
|
|
# Run sanity checks
|
|
- run: cd ee/fleet-agent-downloader/ && npm test
|
|
|
|
# Compile assets
|
|
- run: cd ee/fleet-agent-downloader/ && npm run build-for-prod
|
|
|
|
# Commit newly-built assets locally so we can push them to Heroku below.
|
|
# (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 ee/fleet-agent-downloader/.www
|
|
|
|
# Configure the Heroku app we'll be deploying to
|
|
- run: heroku git:remote -a fleet-agent-downloader
|
|
- run: git remote -v
|
|
|
|
# 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
|
|
|
|
# Deploy to Heroku
|
|
- run: echo "Deploying branch '${GITHUB_REF##*/}' to Heroku…"
|
|
- name: Deploy to Heroku
|
|
run: |
|
|
set -euo pipefail
|
|
git add -A
|
|
# Create a git tree object from the currently staged repository state for this Heroku deploy.
|
|
TREE=$(git write-tree)
|
|
# Create a parentless commit from the tree object.
|
|
COMMIT=$(git -c "user.name=Fleetwood" -c "user.email=github@example.com" \
|
|
commit-tree "$TREE" \
|
|
-m 'AUTOMATED COMMIT - Deploy Fleet agent downloader app with the latest staged changes, including generated production assets.')
|
|
# Push the parentless commit to Heroku
|
|
# Note: The commit pushed to Heroku will not contain the full git history.
|
|
# This lets up deploy this app from the Fleet monorepo while working around Heroku's pack size limits.
|
|
git push heroku "$COMMIT":refs/heads/master --force
|
|
- name: 🌐 Fleet agent downloader has been deployed
|
|
run: echo '' && echo '--' && echo 'OK, done. It should be live momentarily.' && echo '(if you get impatient, check the Heroku dashboard for status)'
|