-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updating workflow.sh * Updating workflow.yml * Rename workflow.yml to action.yml * Refactoring action so it can be used by another workflow. * Update README
- Loading branch information
Showing
5 changed files
with
79 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: fleetctl-gitops | ||
description: Runs fleetctl gitops to apply configuration to Fleet | ||
|
||
inputs: | ||
working-directory: | ||
description: 'The working directory, which should be the root of the fleet-gitops repository.' | ||
default: './' | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install fleetctl | ||
shell: bash | ||
working-directory: ${{ inputs.working-directory }} | ||
run: npm install -g fleetctl | ||
|
||
- name: Configure fleetctl | ||
shell: bash | ||
working-directory: ${{ inputs.working-directory }} | ||
run: fleetctl config set --address ${{ env.FLEET_URL }} --token ${{ env.FLEET_API_TOKEN }} | ||
|
||
- name: Run fleetctl gitops commands | ||
shell: bash | ||
working-directory: ${{ inputs.working-directory }} | ||
run: ./gitops.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
|
||
# -e: Immediately exit if any command has a non-zero exit status. | ||
# -x: Print all executed commands to the terminal. | ||
# -u: Exit if an undefined variable is used. | ||
# -o pipefail: Exit if any command in a pipeline fails. | ||
set -exuo pipefail | ||
|
||
FLEET_GITOPS_DIR="${FLEET_GITOPS_DIR:-./}" | ||
FLEET_GLOBAL_FILE="${FLEET_GLOBAL_FILE:-$FLEET_GITOPS_DIR/default.yml}" | ||
FLEETCTL="${FLEETCTL:-fleetctl}" | ||
|
||
# Validate that global file contains org_settings | ||
grep -Exq "^org_settings:.*" "$FLEET_GLOBAL_FILE" | ||
|
||
if compgen -G "$FLEET_GITOPS_DIR"/teams/*.yml > /dev/null; then | ||
# Validate that every team has a unique name. | ||
# This is a limited check that assumes all team files contain the phrase: `name: <team_name>` | ||
! perl -nle 'print $1 if /^name:\s*(.+)$/' "$FLEET_GITOPS_DIR"/teams/*.yml | sort | uniq -d | grep . -cq | ||
fi | ||
|
||
# Dry run | ||
$FLEETCTL gitops -f "$FLEET_GLOBAL_FILE" --dry-run | ||
for team_file in "$FLEET_GITOPS_DIR"/teams/*.yml; do | ||
if [ -f "$team_file" ]; then | ||
$FLEETCTL gitops -f "$team_file" --dry-run | ||
fi | ||
done | ||
|
||
# Real run | ||
$FLEETCTL gitops -f "$FLEET_GLOBAL_FILE" | ||
for team_file in "$FLEET_GITOPS_DIR"/teams/*.yml; do | ||
if [ -f "$team_file" ]; then | ||
$FLEETCTL gitops -f "$team_file" | ||
fi | ||
done |
This file was deleted.
Oops, something went wrong.