Forking the GitHub Repo - an Alternate Installation Method
Instead of installing EnterprisePolicyAsCode
from the PowerShell Gallery, you can clone the GitHub repository and use the scripts described below to install the script source code. This is useful, if your organization has overly restrictive policies on installing PowerShell modules from the PowerShell Gallery. It can also be useful if you want to contribute EPAC source code to the project.
Setting up your Repo
- Initial setup
- Create
MyForkRepo
as a fork of GitHub repo. - Create
MyWorkingRepo
. 1. Clone your forked repo. 1. Create a new repo from the clone (do not forkMyForkRepo
)
- Create
- Work in
MyWorkingRepo
- While the root folder is not modified as part of the Sync-Repo process, it is recommended that this part of the file structure not be used for storage of any custom material other than new folders.
- You may add additional folders, such as a folder for your own operational scripts.
- Use only folders
Definitions
andPipeline
, except when working on fixes to be contributed back to GitHub.- Review the
Sync-Repo
documentation for additional information on the folders which are destroyed and recreated as part of the version upgrade process for additional insight on this topic.
- Review the
- While the root folder is not modified as part of the Sync-Repo process, it is recommended that this part of the file structure not be used for storage of any custom material other than new folders.
Syncing latest Version from GitHub repo
- Fetch changes from GitHub to
MyForkRepo
. - Execute
Sync-Repo
to copy files fromMyForkRepo
toMyWorkingRepo
feature branch. - PR
MyWorkingRepo
feature branch.
Contribute to GitHub
- Execute
Sync-Repo
to copy files fromMyWorkingRepo
toMyForkRepo
feature branch.- Be sure not to copy internal references within your files during your sync to MyForkRepo.
- PR
MyForkRepo
feature branch. - PR changes in your fork (
MyForkRepo
) to GitHub. - GitHub maintainers will review the PR.
Sync-Repo.ps1
The repo contains script to synchronize directories in both directions: Sync-Repo.ps1
. It only works if you do not modify:
Docs
,Scripts
,Module
andStarterKit
directories*.md
,*.ps1
,*.yml
, andLICENSE
files in repo root directory
Parameter | Required | Explanation |
---|---|---|
SourceDirectory |
Required | Directory with the source (forked repo) |
DestinationDirectory |
Required | Directory with the destination (your private repo) |
SuppressDeleteFiles |
Optional | Switch parameter to suppress deleting files in $destinationDirectory tree |
Process for Development (Maintainers Only)
Warning
This is Intended for maintainers only: It documents how to move internal EPAC development (ADO) to production (GitHub).
Assumptions:
- You have completed PR in for EPAC Development in ADO and are ready to release to public GitHub EPAC project.
- You are using known local path names for EPAC Development repo and GitHub repo, for example:
- EPAC Development local repo:
C:\GitRepoClones\epac-development
- EPAC GitHub local repo:
C:\GitRepoClones\enterprise-azure-policy-as-code
Sync-FromGH.ps1 and Sync-ToGH.ps1
Sync-FromGH.ps1 and Sync-ToGH.ps1 are a wrapper around Sync-Repo.ps1 used by the EPAC maintainers to simplify syncing their development repo epac-development
and the GitHub repo enterprise-azure-policy-as-code
.
Syncing latest Version from GitHub repo to epac-development
repo
- Create a branch in
epac-development repo
namedfeature/sync-from-github
- Sync GitHub enterprise main branch with
Sync-FromGH.ps1
- Verify changes
- Commit changes to
epac-development
branchfeature/sync-from-github
- Test and PR
epac-development
branchfeature/sync-from-github
toepac-development
main branch - Delete
epac-development
branchfeature/sync-from-github
Development in epac-development
repo
- Each developer owns
- Management Group in the
epac-development
tenant - Folder in the
Test
folder,pipeline.yml
, andSet-EnvironmentVariables.ps1
in theepac-development
repo Set-EnvironmentVariables.ps1
in your Test folder is used to set the environment variables for yourTest
folders. This is required for interactively using the scripts.- Create a feature branch in
epac-development
repo namedfeature/<your-name>/<github-issue-number>
- Make and test changes
- PR
epac-development
branchfeature/<your-name>/<github-issue-number>
toepac-development
main branch - Validate "prod" build in
epac-development
tenant - Delete branch
feature/<your-name>/<github-issue-number>
- Fetch main branch from
epac-development
repo - Create a branch in GitHub
enterprise-policy-as-code
repo from the issue you working on. - Fetch that branch in VS Code
- Sync
enterprise-policy-as-code
repo withSync-Repo.ps1
from epac-development repo - Commit changes to
enterprise-policy-as-code
branch created above - validate the changes for conflicts
- PR
enterprise-policy-as-code
branch created above to the main branch - Create a release in GitHub
enterprise-policy-as-code
repo - Delete the branch in
enterprise-policy-as-code
repo
Code Promotion Process
Tip
Modify mkdocs.yml after adding markdown files to the Docs folder.
This process is used to promote code from the EPAC Development repo to the EPAC GitHub repo.
- Create a branch in GitHub (https://github.com/Azure/enterprise-azure-policy-as-code).
- Update local production repo with content from local development repo. In local VS code repo for EPAC GitHub, open terminal:
PS C:\GitRepoClones\enterprise-azure-policy-as-code> .\Sync-ToGH.ps1
. - Commit changes and sync.
- Go to https://github.com/Azure/enterprise-azure-policy-as-code, go to
Compare and Pull Request
- Add PR title and create PR.
- Complete GitHub Review and merge PR process.
- Delete branch from GitHub.
- Go to VSCode for EPAC Release (GitHub) (
C:\GitRepoClones\enterprise-azure-policy-as-code
) - In Source Control, select main branch. Move to Remotes and fetch, then sync changes.
- Move to branches, delete local branch (force delete may be required).
- Open terminal, type
git remote prune origin
- Verify that the documents have been published.
GitHub Releases
This is a guide on how to release a new version of the project - including automated PowerShell module publish. It is used by the EPAC maintainers only.
- Navigate to https://github.com/Azure/enterprise-azure-policy-as-code/releases
- Click on Draft a new release
- Click on Choose a tag and enter in the new release version - it should be in the format "v(major).(minor).(build)" i.e. v7.3.4 Don't forget the v
- When prompted click on Create new tag: vX.X.X on publish
- Add a release title - you can just use the new version number.
- Click on Generate release notes to pull all the notes in from related PRs. Update if necessary.
- Click Publish Release
- Click on Actions
- Verify that a workflow run has started with the same name as the release.
- Verify that the module has been published to the PowerShell Gallery.