-
Notifications
You must be signed in to change notification settings - Fork 53
Adding working GitHub action workflow #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,100 +1,35 @@ | ||
| name: 'Apply latest configuration profiles via Fleet' | ||
| description: 'Applies the latest MDM configuration profiles to a Fleet team' | ||
|
|
||
| inputs: | ||
| FLEET_API_TOKEN: | ||
| description: 'Fleet API Token' | ||
| required: true | ||
| FLEET_URL: | ||
| description: 'Fleet URL' | ||
| required: true | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| repository: ${{ inputs.MDM_CONFIG_REPO }} | ||
|
|
||
| - name: Install fleetctl | ||
| run: npm install -g fleetctl | ||
| shell: bash | ||
|
|
||
| - name: Configure fleetctl | ||
| run: fleetctl config set --address ${{ inputs.FLEET_URL }} --token ${{ inputs.FLEET_API_TOKEN }} | ||
| shell: bash | ||
|
|
||
| - name: Run fleetctl apply | ||
| run: | | ||
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| # STEP 1: Apply config | ||
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| # Combine the contents of all the top-level config into a single YAML document | ||
|
|
||
| # - Include the contents of no-team.controls.yml | ||
| # TODO | ||
|
|
||
| # - Include the contents of default.settings.yml | ||
| # TODO | ||
|
|
||
| # - Include anything of `kind: config` in default.queries.yml | ||
| # TODO | ||
|
|
||
| # - Include anything of `kind: config` in default.policies.yml | ||
| # TODO | ||
|
|
||
| # Apply top-level config with `--replace` (replaces all existing top-level config) | ||
| # TODO | ||
|
|
||
| # Loop through folders in /teams and combine the contents of all team config into a single YAML document | ||
|
|
||
| # - Include the contents of <folder-name>.controls.yml | ||
| # TODO | ||
|
|
||
| # - Include the contents of <folder-name>.settings.yml | ||
| # TODO | ||
|
|
||
| # - Include anything of `kind: team` in <folder-name>.queries.yml | ||
| # TODO | ||
|
|
||
| # - Include anything of `kind: team` in <folder-name>.policies.yml | ||
| # TODO | ||
|
|
||
| # Apply team config with `--replace` (replaces all existing config for this team) | ||
| # TODO | ||
|
|
||
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| # STEP 2: Apply queries | ||
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| # Compile all queries into a single YAML document | ||
|
|
||
| # - Include anything of `kind: query` in default.queries.yml | ||
| # TODO | ||
|
|
||
| # - Loop through folders in /teams and include anything of `kind: query` in <folder-name>.queries.yml for each | ||
| # TODO | ||
|
|
||
| # Apply compiled queries YAML with `--replace` (deletes any queries in Fleet that aren't present in this config) | ||
| # TODO | ||
|
|
||
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| # STEP 3: Apply policies | ||
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| # Compile all policies into a single YAML document | ||
| # TODO | ||
|
|
||
| # - Include anything of `kind: policy` in default.policies.yml | ||
| # TODO | ||
|
|
||
| # - Loop through folders in /teams and include anything of `kind: policy` in <folder-name>.policies.yml for each | ||
| # TODO | ||
|
|
||
| # Apply compiled policies YAML with `--replace` (deletes any policies in Fleet that aren't present in this config) | ||
| # TODO | ||
|
|
||
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| # All done! | ||
| # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
|
|
||
| shell: bash | ||
| name: 'Apply latest configuration to Fleet' | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: # allows manual triggering | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| # Add FLEET_URL and FLEET_API_TOKEN to the repository secrets. | ||
| # In addition, specify or add secrets for all the environment variables that are mentioned in the global/team YAML files. | ||
| env: | ||
| FLEET_SSO_METADATA: ${{ secrets.FLEET_SSO_METADATA }} | ||
| FLEET_GLOBAL_ENROLL_SECRET: ${{ secrets.FLEET_GLOBAL_ENROLL_SECRET }} | ||
| FLEET_WORKSTATIONS_ENROLL_SECRET: ${{ secrets.FLEET_WORKSTATIONS_ENROLL_SECRET }} | ||
| FLEET_WORKSTATIONS_CANARY_ENROLL_SECRET: ${{ secrets.FLEET_WORKSTATIONS_CANARY_ENROLL_SECRET }} | ||
|
|
||
| jobs: | ||
| build-docker: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout GitOps repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install fleetctl | ||
| run: npm install -g fleetctl | ||
|
|
||
| - name: Configure fleetctl | ||
| run: fleetctl config set --address ${{ secrets.FLEET_URL }} --token ${{ secrets.FLEET_API_TOKEN }} | ||
|
|
||
| - name: Run fleetctl gitops commands | ||
| run: ./workflow.sh |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,31 @@ | ||
| #!/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 | ||
|
|
||
| GLOBAL_FILE=./default.yml | ||
| FLEETCTL="${FLEETCTL:-fleetctl}" | ||
|
|
||
| # Validate that global file contains org_settings | ||
| grep -Exq "^org_settings:.*" $GLOBAL_FILE | ||
|
|
||
| if compgen -G ./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*(.+)$/' ./teams/*.yml | sort | uniq -d | grep . -cq | ||
| fi | ||
|
|
||
| # Dry run | ||
| $FLEETCTL gitops -f $GLOBAL_FILE --dry-run | ||
| for team_file in ./teams/*.yml; do | ||
| $FLEETCTL gitops -f "$team_file" --dry-run | ||
| done | ||
|
|
||
| # Real run | ||
| $FLEETCTL gitops -f $GLOBAL_FILE | ||
| for team_file in ./teams/*.yml; do | ||
| $FLEETCTL gitops -f "$team_file" | ||
| done | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.