Skip to content
This repository was archived by the owner on Oct 18, 2025. It is now read-only.

Commit 4a84d17

Browse files
committed
Initial Commit
1 parent af6171f commit 4a84d17

35 files changed

+750
-404
lines changed

.github/gitops-action/action.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: fleetctl-gitops
2+
description: Runs fleetctl gitops to apply configuration to Fleet
3+
4+
inputs:
5+
working-directory:
6+
description: 'The working directory, which should be the root of the fleet-gitops repository.'
7+
default: './'
8+
dry-run-only:
9+
description: 'Whether to only run the fleetctl gitops commands in dry-run mode.'
10+
default: 'false'
11+
delete-other-teams:
12+
description: 'Whether to delete other teams in Fleet which are not part of the gitops config.'
13+
default: 'true'
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- name: Install fleetctl
19+
shell: bash
20+
working-directory: ${{ inputs.working-directory }}
21+
run: |
22+
FLEET_VERSION="$(curl "$FLEET_URL/api/v1/fleet/version" --header "Authorization: Bearer $FLEET_API_TOKEN" --fail --silent | jq --raw-output '.version')"
23+
24+
if [[ -n "$FLEET_VERSION" ]] ; then
25+
npm install -g "fleetctl@$FLEET_VERSION" || npm install -g fleetctl
26+
else
27+
echo "Failed to get Fleet version from $FLEET_URL, installing latest version of fleetctl"
28+
npm install -g fleetctl
29+
fi
30+
31+
- name: Configure fleetctl
32+
shell: bash
33+
working-directory: ${{ inputs.working-directory }}
34+
run: fleetctl config set --address ${{ env.FLEET_URL }} --token ${{ env.FLEET_API_TOKEN }}
35+
36+
- name: Run fleetctl gitops commands
37+
shell: bash
38+
working-directory: ${{ inputs.working-directory }}
39+
env:
40+
FLEET_DRY_RUN_ONLY: ${{ inputs.dry-run-only }}
41+
FLEET_DELETE_OTHER_TEAMS: ${{ inputs.delete-other-teams }}
42+
run: ./gitops.sh

.github/workflows/workflow.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: 'Apply latest configuration to Fleet'
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch: # allows manual triggering
9+
schedule:
10+
- cron: '0 6 * * *' # Nightly 6AM UTC
11+
12+
# Prevent concurrent runs of this workflow.
13+
concurrency:
14+
group: ${{ github.workflow }}
15+
cancel-in-progress: false
16+
17+
defaults:
18+
run:
19+
shell: bash
20+
21+
# Limit permissions of GITHUB_TOKEN.
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
fleet-gitops:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout GitOps repository
30+
uses: actions/checkout@v4
31+
32+
- name: Apply latest configuration to Fleet
33+
uses: ./.github/gitops-action
34+
with:
35+
# Run GitOps in dry-run mode for pull requests.
36+
dry-run-only: ${{ github.event_name == 'pull_request' && 'true' || 'false' }}
37+
# Add FLEET_URL and FLEET_API_TOKEN to the repository secrets.
38+
# In addition, specify or add secrets for all the environment variables that are mentioned in the global/team YAML files.
39+
env:
40+
FLEET_URL: ${{ secrets.FLEET_URL }}
41+
FLEET_API_TOKEN: ${{ secrets.FLEET_API_TOKEN }}
42+
FLEET_GLOBAL_ENROLL_SECRET: ${{ secrets.FLEET_GLOBAL_ENROLL_SECRET }}
43+
FLEET_WORKSTATIONS_ENROLL_SECRET: ${{ secrets.FLEET_WORKSTATIONS_ENROLL_SECRET }}
44+
FLEET_WORKSTATIONS_CANARY_ENROLL_SECRET: ${{ secrets.FLEET_WORKSTATIONS_CANARY_ENROLL_SECRET }}

0 commit comments

Comments
 (0)