This repo contains a forked and modified example of the files and configurations needed to run AutoPKG using GitHub Actions and uploading to Jamf Pro.
I have supplied an example override file for Google Chrome.
The example autopkg.yml
file is set to run on an automated schedule, Monday - Friday at 9am (using Cron time). This workflow file also does the following:
- Checks out the repo where the workflow file exists using the Checkout Action from the GitHub Actions Marketplace
- Installs the stated version of Python using the Setup Python Action from the GitHub Actions Marketplace
- Installs the Python dependencies
- Installs AutoPkg
- Configures AutoPkg and Git
- Uses the autopkg_tools.py script to process each override recipe and creates a pull request if trust info is missing or has changed
- Posts build results to designated Slack channel if integration is set up.
The
autopkg_tools.py
script posts build results to Slack but only trust info changes or if the run has failed. If you would like to see when recipes are processed successfully, add Graham Pugh's JamfUploaderSlacker processor to the end of each of your recipes (view the provided override file for an example).
- Create a new repo with Actions enabled in GitHub.
- Create a .github/workflows directory in GitHub if one doesn’t already exist.
- To view this directory using macOS Finder, make sure to enable viewing hidden files (CMD+Shift+period).
- Clone or copy the autopkg.yml workflow file to the .github/workflows directory in your repository.
- Evaluate this workflow file and decide if you want it to run on an automated schedule or some other way.
- Create the rest of the files and directories within GitHub or your locally cloned repository.
- overrides directory
- autopkg_tools.py
- recipe_list.json
- repo_list.txt
- requirements.txt
- Configure your GitHub Secrets environment with credentials for your Jamf environment, preferably a Jamf account that is dedicated to AutoPkg as well as your Slack Webhook URL (if you want to set up the Slack integration).
- If you use JamfUploader, consider which processors you will be using and grant your Jamf account the correct permissions for the actions you will be taking.
- Create an override recipe and any associated templates and place them in the /overrides directory.
- Add the recipe to recipe_list.json.
- Add the full URL of the parent repository to repo_list.txt.
- Try running your first recipe!
- Click on the Actions tab within your repository
- Click on your workflow file on the left-hand side
- Click the Run Workflow button
- Either enter the path to a single recipe or click the Run Workflow button to run all the recipes in your recipe_list.json file
If you have admin privileges in Slack, the following instructions should work for you, if you don’t then submit a request to your Slack administrator for help creating the application.
- Navigate to https://api.slack.com/apps using your admin profile.
- Click the green Create New App button.
- Give the app a name and choose the workspace you would like to install the app.
- Once you can see the Settings and Features menu of your new app, click on OAuth & Permissions underneath the Features heading.
- Scroll down to Scopes and click Add an OAuth Scope.
- In the drop-down list, scroll down until you see the option for incoming-webhook and select it.
- Once incoming-webhook is added, scroll back up to OAuth Tokens for Your Workspace and click Install to Workspace.
- You will be prompted to select which Slack channel you would like to connect your new Slack app to and click Allow.
- The Slack channel, either public or private, needs to be created before step 8 so that it will show up in this list.
- You will need the following piece of information to add as a secret within your GitHub repository
- Webhook URL which can be found under Settings → Install App.
- Navigate to Settings within your GitHub repository.
- Under Security on the left-hand side, navigate to Secrets → Actions.
- Click New Repository Secret.
- Give the secret a descriptive name.
- Do NOT use dashes or spaces, you can only use camelCase or underscores.
- Add the webhook URL as the secret value.
- Click Add Secret.
The GitHub Actions workflow file is autopkg.yml within each repository
- Under Configure AutoPkg and Git create a new line, copying the previous line starting with
defaults write com.github.autopkg
. - Create a variable name, which will be used in the actual recipes. In the following example,
SANDBOX_API
is the variable name (e.g.defaults write com.github.autopkg SANDBOX_API "${{ secrets.SANDBOX_API_AUTOPKG }}
. - Within the curly brackets “{ }” edit the actual name of the secret to be the secret name you created in GitHub settings.
- Now you can use that variable name in the recipes in this format
%SANDBOX_API%
.
Typically a workflow file can only download packages from public GitHub repositories or a website, but you can use the GitHubReleasesInfoProvider AutoPkg processor to authenticate into a private repository within your GitHub organization.
- Determine what GitHub account you can use as a service account to connect your AutoPkg repository to the other repositories you would like to access and login to that account
- Once you are logged into the Github service account, click on Repositories
- Search for the name of the repository that you are pulling the .pkg from
- If permissions are setup correctly, you should see an option to click on Settings in the repository menu
- The GitHub service account you use needs to be added as a collaborator with admin permissions on the repositories in question so you can access settings. If you cannot access settings, ask someone who does to add your PAT as a secret in the GitHub repository for you
- Once in the repository settings, click on the Secrets drop-down in the left-hand menu, and click on Actions
- Click the New Repository Secret button
- Give the new secret a name
- Paste in your PAT as the value
- Click Add Secret
- Navigate to your autopkg.yml workflow file
- Scroll down to the Configure Autopkg and Git section
- Change the value inside the curly brackets to the name you gave your PAT secret in settings
- Commit your changes
autopkg_tools.py and autopkg.yml from ZenPayroll, Inc., dba Gusto under a BSD 3-clause license.