{"title":"Enter the Cloud Dojo","link":[{"@attributes":{"href":"https:\/\/ghsioux.github.io\/atom.xml","rel":"self"}},{"@attributes":{"href":"https:\/\/ghsioux.github.io\/"}}],"updated":"2025-07-16T12:10:02+02:00","id":"https:\/\/ghsioux.github.io","author":{"name":"ghsioux","email":{}},"entry":[{"title":"Getting Started with GitHub Copilot Coding Agent","link":{"@attributes":{"href":"https:\/\/ghsioux.github.io\/2025\/07\/15\/getting-started-with-copilot-coding-agent"}},"updated":"2025-07-15T00:00:00+02:00","id":"https:\/\/ghsioux.github.io\/2025\/07\/15\/getting-started-with-copilot-coding-agent","content":"<p>Greetings, code ninjas! \ud83e\udd77<\/p>\n\n<p>After helping a customer unlock the power of <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/concepts\/about-copilot-coding-agent#overview-of-copilot-coding-agent\">Copilot Coding Agent<\/a> this morning, I realized this knowledge should be shared with the entire dojo. Consider this your essential scroll of wisdom for getting started with your new AI coding companion.<\/p>\n\n<h2 id=\"1---the-two-paths-of-the-coding-agent\">1 - The Two Paths of the Coding Agent<\/h2>\n\n<p>Like choosing between the way of the sword or the bow, Copilot Coding Agent offers two primary approaches to enhance your coding journey:<\/p>\n\n<h3 id=\"path-1-direct-pr-creation\">Path 1: Direct PR Creation<\/h3>\n<p>Ask Copilot to create a Pull Request directly. This is the swift strike approach - perfect when you know exactly what needs to be done.<\/p>\n<ul>\n  <li>\ud83d\udcd6 <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/how-tos\/agents\/copilot-coding-agent\/asking-copilot-to-create-a-pull-request\">Full documentation on PR creation<\/a><\/li>\n<\/ul>\n\n<h3 id=\"path-2-issue-delegation\">Path 2: Issue Delegation<\/h3>\n<p>Create an issue and assign it to Copilot. This is the strategic approach - ideal for more complex tasks that benefit from structured planning. <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/how-tos\/github-flow\/using-github-copilot-to-create-issues\">Copilot can even help you create well-structured issues<\/a> before delegating them.<\/p>\n<ul>\n  <li>\ud83d\udcd6 <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/how-tos\/agents\/copilot-coding-agent\/using-copilot-to-work-on-an-issue\">Full documentation on issue delegation<\/a><\/li>\n<\/ul>\n\n<h2 id=\"2---essential-scrolls-of-knowledge\">2 - Essential Scrolls of Knowledge<\/h2>\n\n<p>Before embarking on your journey, study these core teachings:<\/p>\n\n<ul>\n  <li>\ud83c\udfaf <strong><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/concepts\/about-copilot-coding-agent\">About Copilot Coding Agent<\/a><\/strong> - Learn how Copilot works autonomously to fix bugs, implement features, improve tests, update docs, and address technical debt;<\/li>\n  <li>\ud83d\udcda <strong><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/how-tos\/agents\/copilot-coding-agent\">Complete Documentation<\/a><\/strong> - The comprehensive guide covering everything from setup to advanced usage:\n    <ul>\n      <li><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/how-tos\/agents\/copilot-coding-agent\/enabling-copilot-coding-agent\">Enabling Copilot coding agent<\/a> for your repository<\/li>\n      <li><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/how-tos\/agents\/copilot-coding-agent\/best-practices-for-using-copilot-to-work-on-tasks\">Best practices<\/a> for optimal results<\/li>\n      <li><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/how-tos\/agents\/copilot-coding-agent\/tracking-copilots-sessions\">Tracking sessions<\/a> to monitor progress<\/li>\n      <li><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/how-tos\/agents\/copilot-coding-agent\/reviewing-a-pull-request-created-by-copilot\">Reviewing PRs<\/a> created by Copilot<\/li>\n      <li><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/how-tos\/agents\/copilot-coding-agent\/extending-copilot-coding-agent-with-mcp\">Extending with MCP<\/a> (Model Context Protocol) for advanced scenarios<\/li>\n      <li><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/how-tos\/agents\/copilot-coding-agent\/customizing-the-development-environment-for-copilot-coding-agent\">Customizing the environment<\/a> with additional tools<\/li>\n      <li><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/how-tos\/agents\/copilot-coding-agent\/customizing-or-disabling-the-firewall-for-copilot-coding-agent\">Customizing the firewall<\/a> to control domain access<\/li>\n      <li><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/how-tos\/agents\/copilot-coding-agent\/troubleshooting-copilot-coding-agent\">Troubleshooting guide<\/a> for common issues<\/li>\n    <\/ul>\n  <\/li>\n<\/ul>\n\n<h2 id=\"3---the-art-of-issue-crafting\">3 - The Art of Issue Crafting<\/h2>\n\n<p>When following Path 2 (issue delegation), remember: <a href=\"https:\/\/github.blog\/developer-skills\/github\/how-to-create-issues-and-pull-requests-in-record-time-on-github\/#h-the-anatomy-of-a-great-github-issue\">a well-structured issue<\/a> is like a perfectly balanced kata. Your AI companion performs best with clear, detailed context and specifications.<\/p>\n\n<p>Leveraging <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/communities\/using-templates-to-encourage-useful-issues-and-pull-requests\/configuring-issue-templates-for-your-repository\">issue templates<\/a> is a great idea to ensure consistent structure and let <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/how-tos\/github-flow\/using-github-copilot-to-create-issues\"><strong>Copilot help create issues<\/strong><\/a> for you with the right content.<\/p>\n\n<p>As you master the art of issue creation, know that GitHub Issues itself is rapidly evolving with powerful new features:<\/p>\n\n<ul>\n  <li><a href=\"https:\/\/github.blog\/changelog\/2025-04-09-evolving-github-issues-and-projects\/#%f0%9f%8f%97%ef%b8%8f-bring-structure-to-your-issues-with-issue-types\">Issue Types<\/a> - Bring structure to your issues with customizable types;<\/li>\n  <li><a href=\"https:\/\/github.blog\/changelog\/2025-04-09-evolving-github-issues-and-projects\/#%f0%9f%94%a8-break-it-down-with-sub-issues\">Sub-Issues<\/a> - Break down complex tasks into manageable sub-issues;<\/li>\n  <li><a href=\"https:\/\/github.com\/orgs\/community\/discussions\/165749\">Issue Dependencies<\/a> - Manage relationships between issues for better workflow orchestration.<\/li>\n<\/ul>\n\n<p>While, as of today, Copilot doesn\u2019t leverage these new issue capabilities directly, we can imagine a future where it could intelligently break down complex requests into sub-issues, respect dependencies, and orchestrate sophisticated multi-phase workflows.<\/p>\n\n<h2 id=\"4---the-way-of-custom-instructions\">4 - The Way of Custom Instructions<\/h2>\n\n<p>Just as a dojo has its own training methods and philosophies, you can teach Copilot Coding Agent to follow your team\u2019s specific practices and coding standards in your repository. This is achieved through <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/how-tos\/agents\/copilot-coding-agent\/best-practices-for-using-copilot-to-work-on-tasks#adding-custom-instructions-to-your-repository\"><strong>repository custom instructions<\/strong><\/a> - a powerful feature that ensures your AI companion adheres to your project\u2019s unique requirements.<\/p>\n\n<p>You can have a look at the <code class=\"language-plaintext highlighter-rouge\">instructions<\/code> folder of the <a href=\"https:\/\/github.com\/github\/awesome-copilot\/\">awesome-copilot repository<\/a> for inspiration.<\/p>\n\n<p>For VS Code users, you can automatically generate a <code class=\"language-plaintext highlighter-rouge\">.github\/copilot-instructions.md<\/code> file tailored to your project (<a href=\"https:\/\/code.visualstudio.com\/docs\/copilot\/copilot-customization#_generate-an-instructions-file-for-your-workspace\">learn more here<\/a>).<\/p>\n\n<h2 id=\"5---the-path-forward\">5 - The Path Forward<\/h2>\n\n<p>As you begin your journey with Copilot Coding Agent, remember that mastery comes through practice. Start with simple tasks, observe how your AI companion approaches problems, and gradually increase complexity.<\/p>\n\n<p>For those seeking to push beyond current boundaries, keep an eye on <a href=\"https:\/\/githubnext.com\/\">GitHub Next<\/a> where the future of AI-assisted development is being forged.<\/p>\n\n<p>May your code be bug-free and your deployments swift!<\/p>\n\n<p>Gassh\u014d \ud83d\ude4f<\/p>\n\n<h4 id=\"additional-readings-from-the-github-blog\">Additional Readings from the GitHub Blog<\/h4>\n\n<blockquote>\n  <p><strong>Note:<\/strong> GitHub Copilot Coding Agent is rapidly evolving! Some content in these posts reflects the development phase and may be outdated. Always check the <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/copilot\/how-tos\/agents\/copilot-coding-agent\">official documentation<\/a> for the most current information.<\/p>\n<\/blockquote>\n\n<ul>\n  <li><strong>July 15, 2025<\/strong> - <strong><a href=\"https:\/\/github.blog\/ai-and-ml\/github-copilot\/from-chaos-to-clarity-using-github-copilot-agents-to-improve-developer-workflows\/\">From chaos to clarity: Using GitHub Copilot agents to improve developer workflows<\/a><\/strong> - Learn how to set up Copilot coding agent for success.<\/li>\n  <li><strong>July 1, 2025<\/strong> - <strong><a href=\"https:\/\/github.blog\/ai-and-ml\/github-copilot\/from-idea-to-pr-a-guide-to-github-copilots-agentic-workflows\/\">From idea to PR: A guide to GitHub Copilot\u2019s agentic workflows<\/a><\/strong> - A practical guide demonstrating how to use Copilot\u2019s coding agent.<\/li>\n  <li><strong>June 6, 2025<\/strong> - <strong><a href=\"https:\/\/github.blog\/ai-and-ml\/github-copilot\/assigning-and-completing-issues-with-coding-agent-in-github-copilot\/\">Assigning and completing issues with coding agent in GitHub Copilot<\/a><\/strong> - A detailed walkthrough of the issue delegation workflow.<\/li>\n  <li><strong>June 5, 2025<\/strong> - <strong><a href=\"https:\/\/github.blog\/developer-skills\/github\/how-to-create-issues-and-pull-requests-in-record-time-on-github\/\">How to create issues and pull requests in record time<\/a><\/strong> - Learn the anatomy of well-structured issues and how Copilot amplifies your workflow.<\/li>\n<\/ul>\n\n"},{"title":"7 Cool Things You Can Do with GitHub Rulesets","link":{"@attributes":{"href":"https:\/\/ghsioux.github.io\/2025\/01\/09\/7-cool-things-with-rulesets"}},"updated":"2025-01-09T00:00:00+01:00","id":"https:\/\/ghsioux.github.io\/2025\/01\/09\/7-cool-things-with-rulesets","content":"<p>As a GitHub enthusiast, I strive to make my repositories as pristine, efficient, and secure as a shinobi\u2019s blade \ud83e\udd77\u2694\ufe0f. Enter GitHub <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/repositories\/configuring-branches-and-merges-in-your-repository\/managing-rulesets\/about-rulesets\">rulesets<\/a> - a potent tool for automating and enforcing best practices across repositories and organizations.<\/p>\n\n<p>While GitHub already offers some <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/repositories\/configuring-branches-and-merges-in-your-repository\/managing-rulesets\/creating-rulesets-for-a-repository#useful-regular-expression-patterns\">nice examples<\/a> (like ensuring tags follow the <a href=\"https:\/\/semver.org\/\">semantic versioning<\/a> scheme) and <a href=\"https:\/\/github.com\/github\/ruleset-recipes\">ruleset recipes<\/a>, I wanted to take things a bit further. In this post, we\u2019ll explore 7 powerful and practical ways to supercharge your repositories using GitHub rulesets.<\/p>\n\n<p>What makes this special? These use cases come straight from real-world customer challenges and scenarios I\u2019ve tackled.<\/p>\n\n<blockquote>\n  <p>\u26a1\ufe0f For each example, you\u2019ll find the corresponding ruleset JSON in the associated section and in <a href=\"https:\/\/github.com\/ghsioux\/cool-rulesets\/\">this repository<\/a>, ready for <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/repositories\/configuring-branches-and-merges-in-your-repository\/managing-rulesets\/managing-rulesets-for-a-repository#importing-a-ruleset\">import<\/a> into your own environment. Let\u2019s get started!<\/p>\n<\/blockquote>\n\n<h3 id=\"1-prevent-unauthorized-cicd-changes\">1. Prevent Unauthorized CI\/CD Changes<\/h3>\n\n<p>Protecting your CI\/CD specifications from unauthorized changes is critical for maintaining a secure and reliable pipeline. This push ruleset prevents direct pushes to the <code class=\"language-plaintext highlighter-rouge\">.github\/workflows\/<\/code> directory using <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/repositories\/configuring-branches-and-merges-in-your-repository\/managing-rulesets\/available-rules-for-rulesets#restrict-file-paths\">a path restriction<\/a>, ensuring that only repository administrators can modify GitHub Actions workflows. This adds an additional layer of protection to your CI\/CD processes.<\/p>\n\n<details class=\"details-container\">\n  <summary class=\"details-summary\"> \ud83d\udcdc Ruleset JSON<\/summary>\n\n\n<figure class=\"highlight\"><pre><code class=\"language-json\" data-lang=\"json\"><span class=\"p\">{<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"id\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"mi\">2949246<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"name\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"forbid-cicd-changes\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"target\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"push\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"source_type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"Repository\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"source\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"ghsioux\/cool-rulesets\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"enforcement\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"active\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"conditions\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"kc\">null<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"rules\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n    <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"file_path_restriction\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"parameters\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"restricted_file_paths\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n          <\/span><span class=\"s2\">\".github\/workflows\/*\"<\/span><span class=\"w\">\n        <\/span><span class=\"p\">]<\/span><span class=\"w\">\n      <\/span><span class=\"p\">}<\/span><span class=\"w\">\n    <\/span><span class=\"p\">}<\/span><span class=\"w\">\n  <\/span><span class=\"p\">],<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"bypass_actors\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n    <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"actor_id\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"mi\">5<\/span><span class=\"p\">,<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"actor_type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"RepositoryRole\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"bypass_mode\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"always\"<\/span><span class=\"w\">\n    <\/span><span class=\"p\">}<\/span><span class=\"w\">\n  <\/span><span class=\"p\">]<\/span><span class=\"w\">\n<\/span><span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n\n<\/details>\n\n<h5 id=\"other-use-cases\">Other Use-Cases<\/h5>\n\n<ul>\n  <li><strong>Lock deployment scripts<\/strong>: Protect files like <code class=\"language-plaintext highlighter-rouge\">scripts\/deploy.sh<\/code> to prevent unauthorized modifications.<\/li>\n  <li><strong>Secure infrastructure-as-code files<\/strong>: Restrict changes to critical files such as <code class=\"language-plaintext highlighter-rouge\">terraform\/*.tf<\/code>.<\/li>\n  <li><strong>Protect configuration files<\/strong>: Limit updates to sensitive configurations, e.g., <code class=\"language-plaintext highlighter-rouge\">config\/*.yml<\/code>.<\/li>\n  <li><strong>Control dependency updates<\/strong>: Restrict updates to files like <code class=\"language-plaintext highlighter-rouge\">package.json<\/code> or <code class=\"language-plaintext highlighter-rouge\">requirements.txt<\/code> for tighter dependency management.<\/li>\n<\/ul>\n\n<h3 id=\"2-enforce-shorter-file-paths-for-legacy-system-compatibility\">2. Enforce Shorter File Paths for Legacy System Compatibility<\/h3>\n\n<p>Legacy systems often have strict file path length constraints, and exceeding these can cause deployment failures or runtime errors. This push ruleset ensures all file <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/repositories\/configuring-branches-and-merges-in-your-repository\/managing-rulesets\/available-rules-for-rulesets#restrict-file-path-length\">paths remain within a defined limit<\/a>, preventing longer paths from being committed. It\u2019s an essential safeguard for repositories interacting with older or constrained systems.<\/p>\n\n<details class=\"details-container\">\n  <summary class=\"details-summary\"> \ud83d\udcdc Ruleset JSON<\/summary>\n\n\n<figure class=\"highlight\"><pre><code class=\"language-json\" data-lang=\"json\"><span class=\"p\">{<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"id\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"mi\">2950733<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"name\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"legacy-system-filepath\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"target\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"push\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"source_type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"Repository\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"source\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"ghsioux\/cool-rulesets\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"enforcement\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"active\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"conditions\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"kc\">null<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"rules\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n    <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"max_file_path_length\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"parameters\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"max_file_path_length\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"mi\">255<\/span><span class=\"w\">\n      <\/span><span class=\"p\">}<\/span><span class=\"w\">\n    <\/span><span class=\"p\">}<\/span><span class=\"w\">\n  <\/span><span class=\"p\">],<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"bypass_actors\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[]<\/span><span class=\"w\">\n<\/span><span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n\n<\/details>\n\n<h5 id=\"other-use-cases-1\">Other Use-Cases<\/h5>\n\n<ul>\n  <li><strong>Deployment reliability<\/strong>: Avoid issues during ZIP file generation or deployment processes caused by excessively long paths.<\/li>\n  <li><strong>Repository organization<\/strong>: Maintain clean, manageable, and well-structured repositories by limiting overly nested file paths.<\/li>\n<\/ul>\n\n<h3 id=\"3-block-binary-files-from-being-pushed-into-the-repository\">3. Block Binary Files from Being Pushed into the Repository<\/h3>\n\n<p>Preventing binary files from being pushed into your repository avoids unnecessary bloat, ensures faster cloning, and maintains better compatibility with Git versioning tools. This push ruleset <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/repositories\/configuring-branches-and-merges-in-your-repository\/managing-rulesets\/available-rules-for-rulesets#restrict-file-extensions\">restricts common binary file extensions<\/a>, such as <code class=\"language-plaintext highlighter-rouge\">.exe<\/code>, <code class=\"language-plaintext highlighter-rouge\">.bin<\/code>, <code class=\"language-plaintext highlighter-rouge\">.dll<\/code>, and more.<\/p>\n\n<details class=\"details-container\">\n  <summary class=\"details-summary\"> \ud83d\udcdc Ruleset JSON<\/summary>\n\n\n<figure class=\"highlight\"><pre><code class=\"language-json\" data-lang=\"json\"><span class=\"p\">{<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"id\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"mi\">3003094<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"name\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"forbid-binary-files\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"target\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"push\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"source_type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"Repository\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"source\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"ghsioux\/cool-rulesets\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"enforcement\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"active\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"conditions\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"kc\">null<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"rules\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n    <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"file_extension_restriction\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"parameters\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"restricted_file_extensions\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n          <\/span><span class=\"s2\">\"*.exe\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.bin\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.dll\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.so\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.dmg\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.msi\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.app\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n          <\/span><span class=\"s2\">\"*.zip\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.tar\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.gz\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.rar\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.7z\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.xz\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.bz2\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n          <\/span><span class=\"s2\">\"*.iso\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.vmdk\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.qcow2\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.img\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n          <\/span><span class=\"s2\">\"*.dat\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.db\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.sqlite\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.bak\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.ldf\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.mdf\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n          <\/span><span class=\"s2\">\"*.ttf\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.otf\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.woff\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.woff2\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.eot\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n          <\/span><span class=\"s2\">\"*.dwg\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.dxf\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.stl\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.3ds\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.obj\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n          <\/span><span class=\"s2\">\"*.doc\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.docx\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.xls\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.xlsx\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.ppt\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.pptx\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> \n          <\/span><span class=\"s2\">\"*.pdf\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.swp\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.tmp\"<\/span><span class=\"p\">,<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"*.bak\"<\/span><span class=\"w\">\n        <\/span><span class=\"p\">]<\/span><span class=\"w\">\n      <\/span><span class=\"p\">}<\/span><span class=\"w\">\n    <\/span><span class=\"p\">}<\/span><span class=\"w\">\n  <\/span><span class=\"p\">],<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"bypass_actors\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[]<\/span><span class=\"w\">\n<\/span><span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n\n<\/details>\n\n<h5 id=\"other-use-cases-2\">Other Use-Cases<\/h5>\n\n<ul>\n  <li><strong>Media file management<\/strong>: For file types like <code class=\"language-plaintext highlighter-rouge\">.jpg<\/code>, <code class=\"language-plaintext highlighter-rouge\">.png<\/code>, <code class=\"language-plaintext highlighter-rouge\">.mp4<\/code>, or <code class=\"language-plaintext highlighter-rouge\">.mp3<\/code>, consider creating a specific ruleset or leveraging <a href=\"https:\/\/git-lfs.github.com\/\">Git LFS<\/a> for efficient storage.<\/li>\n  <li><strong>Optimize code review processes<\/strong>: Restrict binary files to ensure that code analysis and review tools function without interference, focusing exclusively on source code.<\/li>\n  <li><strong>Prevent malware spread<\/strong>: Block potentially harmful files (e.g., <code class=\"language-plaintext highlighter-rouge\">.exe<\/code>, <code class=\"language-plaintext highlighter-rouge\">.dll<\/code>, <code class=\"language-plaintext highlighter-rouge\">.vbs<\/code>, <code class=\"language-plaintext highlighter-rouge\">.js<\/code>, <code class=\"language-plaintext highlighter-rouge\">.bat<\/code>) from being pushed to the repository, reducing the risk of malware distribution within the codebase and ensuring a safer environment for contributors.<\/li>\n<\/ul>\n\n<h3 id=\"4-restrict-commits-to-authors-with-company-email-addresses\">4. Restrict Commits to Authors with Company Email Addresses<\/h3>\n\n<p>Ensuring that commits come from authorized sources is crucial for compliance, accountability, and security. By restricting commits to authors with company email addresses, you can maintain organizational standards and prevent unauthorized contributions. This push ruleset <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/repositories\/configuring-branches-and-merges-in-your-repository\/managing-rulesets\/available-rules-for-rulesets#metadata-restrictions\">validates the commit author\u2019s email pattern<\/a> before allowing the commit to proceed.<\/p>\n\n<details class=\"details-container\">\n  <summary class=\"details-summary\">\ud83d\udcdc Ruleset JSON<\/summary>\n\n\n<figure class=\"highlight\"><pre><code class=\"language-json\" data-lang=\"json\"><span class=\"p\">{<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"id\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"mi\">3003187<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"name\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"commit-with-company-email\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"target\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"branch\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"source_type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"Repository\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"source\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"ghsioux\/cool-rulesets\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"enforcement\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"active\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"conditions\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"kc\">null<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"rules\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n    <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"commit_author_email_pattern\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"parameters\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"operator\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"regex\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"pattern\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"^[a-zA-Z0-9._%+-]+@company-domain<\/span><span class=\"se\">\\\\<\/span><span class=\"s2\">.com$\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"negate\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"kc\">false<\/span><span class=\"p\">,<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"name\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"\"<\/span><span class=\"w\">\n      <\/span><span class=\"p\">}<\/span><span class=\"w\">\n    <\/span><span class=\"p\">}<\/span><span class=\"w\">\n  <\/span><span class=\"p\">],<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"bypass_actors\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[]<\/span><span class=\"w\">\n<\/span><span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<\/details>\n\n<h5 id=\"other-use-cases-3\">Other Use-Cases<\/h5>\n<ul>\n  <li><strong>Audit and compliance<\/strong>: Maintain clear traceability of contributions to ensure that only internal team members are making changes, which is especially useful for security audits and compliance checks.<\/li>\n  <li><strong>Enforce code ownership and responsibility<\/strong>: Helps track and maintain clear ownership, ensuring accountability for code contributions.<\/li>\n<\/ul>\n\n<h3 id=\"5-enforce-branch-naming-patterns\">5. Enforce Branch Naming Patterns<\/h3>\n\n<p>Maintaining a clear and consistent branch naming structure is vital for effective collaboration and repository organization. Enforcing branch naming conventions, such as <code class=\"language-plaintext highlighter-rouge\">feature\/*<\/code>, <code class=\"language-plaintext highlighter-rouge\">bugfix\/*<\/code>, or <code class=\"language-plaintext highlighter-rouge\">release\/*<\/code>, ensures that branches align with your team\u2019s development workflows. This branch ruleset helps streamline collaboration, making it easier to manage and identify different types of work, whether it\u2019s new features, bug fixes, or preparation for releases.<\/p>\n\n<details class=\"details-container\">\n  <summary class=\"details-summary\">\ud83d\udcdc Ruleset JSON<\/summary>\n\n\n<figure class=\"highlight\"><pre><code class=\"language-json\" data-lang=\"json\"><span class=\"p\">{<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"id\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"mi\">3139547<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"name\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"enforce-branch-naming-convention\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"target\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"branch\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"source_type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"Repository\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"source\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"ghsioux\/cool-rulesets\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"enforcement\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"active\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"conditions\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n    <\/span><span class=\"nl\">\"ref_name\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"exclude\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n        <\/span><span class=\"s2\">\"refs\/heads\/releases\/**\/*\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n        <\/span><span class=\"s2\">\"refs\/heads\/feature\/**\/*\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n        <\/span><span class=\"s2\">\"refs\/heads\/hotfix\/**\/*\"<\/span><span class=\"w\">\n      <\/span><span class=\"p\">],<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"include\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[]<\/span><span class=\"w\">\n    <\/span><span class=\"p\">}<\/span><span class=\"w\">\n  <\/span><span class=\"p\">},<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"rules\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n    <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"creation\"<\/span><span class=\"w\">\n    <\/span><span class=\"p\">}<\/span><span class=\"w\">\n  <\/span><span class=\"p\">],<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"bypass_actors\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[]<\/span><span class=\"w\">\n<\/span><span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<\/details>\n\n<h5 id=\"additional-use-cases\">Additional Use Cases<\/h5>\n<ul>\n  <li><strong>Track specific work areas<\/strong>: Use naming conventions like <code class=\"language-plaintext highlighter-rouge\">ui\/*<\/code>, <code class=\"language-plaintext highlighter-rouge\">backend\/*<\/code>, or <code class=\"language-plaintext highlighter-rouge\">api\/*<\/code> to categorize branches based on the type of work being done. This helps teams easily identify which parts of the application are being worked on and fosters better cross-functional collaboration.<\/li>\n  <li><strong>Support multiple environments<\/strong>: Enforce patterns such as <code class=\"language-plaintext highlighter-rouge\">dev\/*<\/code>, <code class=\"language-plaintext highlighter-rouge\">qa\/*<\/code>, <code class=\"language-plaintext highlighter-rouge\">prod\/*<\/code> for branches associated with different environments, ensuring each stage of the deployment pipeline is clearly defined and tracked.<\/li>\n  <li><strong>Improved automated pipeline integration<\/strong>: Name branches like <code class=\"language-plaintext highlighter-rouge\">release\/*<\/code> or <code class=\"language-plaintext highlighter-rouge\">feature\/*<\/code> to trigger specific actions in CI\/CD pipelines, such as deployment to staging or triggering automated tests.<\/li>\n<\/ul>\n\n<h3 id=\"6-protecting-the-production-branch\">6. Protecting The Production Branch<\/h3>\n\n<p>One of the most common and important rulesets in GitHub Enterprise accounts is protecting the production branch (e.g. <code class=\"language-plaintext highlighter-rouge\">main<\/code>). Ensuring its integrity is essential for stable deployments and maintaining a reliable codebase. This branch ruleset enforces strict requirements for merging feature branches, guaranteeing that only thoroughly reviewed, high-quality, and secure code makes it to production.<\/p>\n\n<p>This ruleset <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/repositories\/configuring-branches-and-merges-in-your-repository\/managing-rulesets\/available-rules-for-rulesets#require-a-pull-request-before-merging\">requires the use of a pull request<\/a>, which enforces the following safeguards:<\/p>\n\n<ul>\n  <li><strong>Code review<\/strong>: At least 3 approvals are required, including from <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/repositories\/managing-your-repositorys-settings-and-features\/customizing-your-repository\/about-code-owners\">Code Owners<\/a>.<\/li>\n  <li><strong>Build and test<\/strong>: A GitHub Actions <a href=\"https:\/\/github.com\/ghsioux\/cool-rulesets\/blob\/main\/.github\/workflows\/build-and-test.yml#L14\">job<\/a> must successfully execute a build and run tests - this is what we call a <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/repositories\/configuring-branches-and-merges-in-your-repository\/managing-rulesets\/available-rules-for-rulesets#require-status-checks-to-pass-before-merging\">required status check<\/a>.<\/li>\n  <li><strong>Security scanning<\/strong>: A CodeQL scan must succeed, with no high or critical security alerts (this requires <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/get-started\/learning-about-github\/about-github-advanced-security\">GitHub Advanced Security<\/a>).<\/li>\n<\/ul>\n\n<p>A bypass list has been added to this ruleset, enabling repository owners to bypass it in critical situations, providing flexibility when needed.<\/p>\n\n<details class=\"details-container\">\n  <summary class=\"details-summary\"> \ud83d\udcdc Ruleset JSON<\/summary>\n\n\n<figure class=\"highlight\"><pre><code class=\"language-json\" data-lang=\"json\"><span class=\"p\">{<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"id\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"mi\">106399<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"name\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"production-branch-protection\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"target\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"branch\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"source_type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"Repository\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"source\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"ghsioux\/cool-rulesets\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"enforcement\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"active\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"conditions\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n    <\/span><span class=\"nl\">\"ref_name\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"exclude\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[],<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"include\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n        <\/span><span class=\"s2\">\"~DEFAULT_BRANCH\"<\/span><span class=\"w\"> \n      <\/span><span class=\"p\">]<\/span><span class=\"w\">\n    <\/span><span class=\"p\">}<\/span><span class=\"w\">\n  <\/span><span class=\"p\">},<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"rules\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n    <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"pull_request\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"parameters\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"required_approving_review_count\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"mi\">3<\/span><span class=\"p\">,<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"dismiss_stale_reviews_on_push\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"kc\">false<\/span><span class=\"p\">,<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"require_code_owner_review\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"kc\">true<\/span><span class=\"p\">,<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"require_last_push_approval\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"kc\">true<\/span><span class=\"p\">,<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"required_review_thread_resolution\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"kc\">true<\/span><span class=\"w\">\n      <\/span><span class=\"p\">}<\/span><span class=\"w\">\n    <\/span><span class=\"p\">},<\/span><span class=\"w\">\n    <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"required_status_checks\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"parameters\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"strict_required_status_checks_policy\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"kc\">true<\/span><span class=\"p\">,<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"do_not_enforce_on_create\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"kc\">true<\/span><span class=\"p\">,<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"required_status_checks\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n          <\/span><span class=\"p\">{<\/span><span class=\"w\">\n            <\/span><span class=\"nl\">\"context\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"\ud83d\udea7 - Build &amp; Test\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n            <\/span><span class=\"nl\">\"integration_id\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"mi\">15368<\/span><span class=\"w\">\n          <\/span><span class=\"p\">}<\/span><span class=\"w\">\n        <\/span><span class=\"p\">]<\/span><span class=\"w\">\n      <\/span><span class=\"p\">}<\/span><span class=\"w\">\n    <\/span><span class=\"p\">},<\/span><span class=\"w\">\n    <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"code_scanning\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"parameters\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"code_scanning_tools\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n          <\/span><span class=\"p\">{<\/span><span class=\"w\">\n            <\/span><span class=\"nl\">\"tool\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"CodeQL\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n            <\/span><span class=\"nl\">\"security_alerts_threshold\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"high_or_higher\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n            <\/span><span class=\"nl\">\"alerts_threshold\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"errors\"<\/span><span class=\"w\">\n          <\/span><span class=\"p\">}<\/span><span class=\"w\">\n        <\/span><span class=\"p\">]<\/span><span class=\"w\">\n      <\/span><span class=\"p\">}<\/span><span class=\"w\">\n    <\/span><span class=\"p\">}<\/span><span class=\"w\">\n  <\/span><span class=\"p\">],<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"bypass_actors\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n    <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"actor_id\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"mi\">5<\/span><span class=\"p\">,<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"actor_type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"RepositoryRole\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"bypass_mode\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"always\"<\/span><span class=\"w\">\n    <\/span><span class=\"p\">}<\/span><span class=\"w\">\n  <\/span><span class=\"p\">]<\/span><span class=\"w\">\n<\/span><span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n\n<\/details>\n\n<h5 id=\"other-use-cases-4\">Other Use-Cases<\/h5>\n\n<ul>\n  <li><strong>Enforce quality gates<\/strong>: Add more required status checks, e.g. to ensure specific code coverage thresholds.<\/li>\n  <li><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/repositories\/configuring-branches-and-merges-in-your-repository\/managing-rulesets\/available-rules-for-rulesets#additional-settings\"><strong>Control merge methods<\/strong><\/a>: Restrict merge methods (e.g., squash-only) for a consistent Git history.<\/li>\n  <li><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/repositories\/configuring-branches-and-merges-in-your-repository\/managing-rulesets\/available-rules-for-rulesets#require-deployments-to-succeed-before-merging\"><strong>Require deployment validation<\/strong><\/a>: Ensure changes are successfully deployed and tested in staging <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/actions\/writing-workflows\/choosing-what-your-workflow-does\/using-environments-for-deployment\">environment<\/a> before merging to production.<\/li>\n<\/ul>\n\n<h3 id=\"7-ensure-code-adheres-to-linting-standards-before-merging\">7. Ensure Code Adheres to Linting Standards Before Merging<\/h3>\n\n<p>Maintaining consistent code quality across an organization requires enforcement of linting and formatting standards. This <strong>organization-level<\/strong> ruleset leverages <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/organizations\/managing-organization-settings\/managing-custom-properties-for-repositories-in-your-organization\">repository custom properties<\/a> and <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/repositories\/configuring-branches-and-merges-in-your-repository\/managing-rulesets\/available-rules-for-rulesets#require-workflows-to-pass-before-merging\">required workflows<\/a> to ensure that branches in critical JavaScript\/TypeScript repositories adhere to an organization-provided linting workflow before changes can be merged into the default branch.<\/p>\n\n<p>Unlike repository-specific rulesets, this organization-wide approach scales effortlessly, applying uniform rules across all repositories meeting the defined criteria. Also, note that organization admins can <strong>bypass<\/strong> this ruleset if needed.<\/p>\n\n<details class=\"details-container\">\n  <summary class=\"details-summary\">\ud83d\udcdc Ruleset JSON<\/summary>\n\n\n<figure class=\"highlight\"><pre><code class=\"language-json\" data-lang=\"json\"><span class=\"p\">{<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"id\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"mi\">3135923<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"name\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"enforce-org-linting-standard\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"target\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"branch\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"source_type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"Organization\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"source\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"ghsioux-example-org\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"enforcement\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"active\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"conditions\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n    <\/span><span class=\"nl\">\"ref_name\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"exclude\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[],<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"include\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n        <\/span><span class=\"s2\">\"~DEFAULT_BRANCH\"<\/span><span class=\"w\">\n      <\/span><span class=\"p\">]<\/span><span class=\"w\">\n    <\/span><span class=\"p\">},<\/span><span class=\"w\">\n    <\/span><span class=\"nl\">\"repository_property\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"exclude\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[],<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"include\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n        <\/span><span class=\"p\">{<\/span><span class=\"w\">\n          <\/span><span class=\"nl\">\"name\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"language\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n          <\/span><span class=\"nl\">\"source\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"system\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n          <\/span><span class=\"nl\">\"property_values\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n            <\/span><span class=\"s2\">\"JavaScript\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n            <\/span><span class=\"s2\">\"TypeScript\"<\/span><span class=\"w\">\n          <\/span><span class=\"p\">]<\/span><span class=\"w\">\n        <\/span><span class=\"p\">},<\/span><span class=\"w\">\n        <\/span><span class=\"p\">{<\/span><span class=\"w\">\n          <\/span><span class=\"nl\">\"name\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"criticality\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n          <\/span><span class=\"nl\">\"source\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"custom\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n          <\/span><span class=\"nl\">\"property_values\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n            <\/span><span class=\"s2\">\"high\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n            <\/span><span class=\"s2\">\"medium\"<\/span><span class=\"w\">\n          <\/span><span class=\"p\">]<\/span><span class=\"w\">\n        <\/span><span class=\"p\">}<\/span><span class=\"w\">\n      <\/span><span class=\"p\">]<\/span><span class=\"w\">\n    <\/span><span class=\"p\">}<\/span><span class=\"w\">\n  <\/span><span class=\"p\">},<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"rules\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n    <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"workflows\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"parameters\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">{<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"do_not_enforce_on_create\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"kc\">true<\/span><span class=\"p\">,<\/span><span class=\"w\">\n        <\/span><span class=\"nl\">\"workflows\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n          <\/span><span class=\"p\">{<\/span><span class=\"w\">\n            <\/span><span class=\"nl\">\"repository_id\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"mi\">586945170<\/span><span class=\"p\">,<\/span><span class=\"w\">\n            <\/span><span class=\"nl\">\"path\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\".github\/workflows\/lint.yaml\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n            <\/span><span class=\"nl\">\"ref\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"refs\/heads\/main\"<\/span><span class=\"w\">\n          <\/span><span class=\"p\">}<\/span><span class=\"w\">\n        <\/span><span class=\"p\">]<\/span><span class=\"w\">\n      <\/span><span class=\"p\">}<\/span><span class=\"w\">\n    <\/span><span class=\"p\">}<\/span><span class=\"w\">\n  <\/span><span class=\"p\">],<\/span><span class=\"w\">\n  <\/span><span class=\"nl\">\"bypass_actors\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p\">[<\/span><span class=\"w\">\n    <\/span><span class=\"p\">{<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"actor_id\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"mi\">1<\/span><span class=\"p\">,<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"actor_type\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"OrganizationAdmin\"<\/span><span class=\"p\">,<\/span><span class=\"w\">\n      <\/span><span class=\"nl\">\"bypass_mode\"<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s2\">\"always\"<\/span><span class=\"w\">\n    <\/span><span class=\"p\">}<\/span><span class=\"w\">\n  <\/span><span class=\"p\">]<\/span><span class=\"w\">\n<\/span><span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<\/details>\n\n<h5 id=\"other-use-cases-5\">Other Use-Cases<\/h5>\n\n<p>You can extend the concept of organization rulesets to implement compliance and consistency across repositories in your organization, such as by enforcing test automation, security scanning, and even the previous rulesets, ensuring that all projects follow the same processes.<\/p>\n\n<h3 id=\"-bonus-\">\ud83c\udf00 Bonus \ud83c\udf00<\/h3>\n\n<p>Congratulations on making it to the end! That\u2019s the spirit of a true shinobi. To start the new year on a high note, here are some bonus tips just for you.<\/p>\n\n<h4 id=\"bonus-1-enterprise-rulesets\">Bonus 1: Enterprise Rulesets<\/h4>\n\n<p>Until now, we\u2019ve focused on repository and organization-level rulesets. With <a href=\"https:\/\/github.blog\/changelog\/2024-12-04-enterprise-repository-properties-policies-and-rulesets-public-preview\/\">a recent update<\/a>, you can now also create <strong>enterprise-level rulesets<\/strong>. If you\u2019re an <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/admin\/managing-accounts-and-repositories\/managing-users-in-your-enterprise\/roles-in-an-enterprise#enterprise-owners\">enterprise owner<\/a> on GitHub Enterprise, this is a powerful game-changer that streamlines governance and ensures consistency at scale across your organizations.<\/p>\n\n<h4 id=\"bonus-2-enterprise-repository-policies\">Bonus 2: Enterprise Repository Policies<\/h4>\n<p>Building on the same update, you can now define <strong>repository policies<\/strong> at the enterprise level. This gives you the ability to enforce consistent rules across repositories throughout your entire enterprise, improving centralized management and governance across organizations.<\/p>\n\n<p>Here are a few examples (click to expand):<\/p>\n\n<details class=\"details-container\">\n    <summary class=\"details-summary\">\ud83d\udcf8 Protect Critical Repositories from Being Deleted<\/summary>\n    \n    This policy ensures that only organization admins can delete repositories labeled with the custom property <code>\"criticality\": \"high\"<\/code>. This safeguard prevents both accidental and malicious deletions. It is enforced across all organizations within the enterprise, helping to protect repositories that are essential for your organization's operations and security.\n\n    <img src=\"\/assets\/images\/2025-01-09-7-cool-things-with-rulesets\/prevent-critical-repos-deletion.png\" alt=\"prevent critical repos deletion in enterprise\" \/>\n<\/details>\n\n<details class=\"details-container\">\n    <summary class=\"details-summary\">\ud83d\udcf8 Restrict Public Repository Creation <\/summary>    \n\n    This policy restricts the creation of public repositories within your enterprise. It ensures that repositories can only be created as private or internal to promote innersourcing. This is an important safeguard to protect sensitive data and intellectual property from being exposed to the public. Note that this is the default behavior with <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/admin\/managing-iam\/understanding-iam-for-enterprises\/about-enterprise-managed-users\">Enterprise Managed Users<\/a>.\n    <img src=\"\/assets\/images\/2025-01-09-7-cool-things-with-rulesets\/prevent-public-repo.png\" alt=\"prevent public repos in enterprise\" \/>\n<\/details>\n\n<details class=\"details-container\">\n    <summary class=\"details-summary\">\ud83d\udcf8 Enforce Repository Naming Conventions for IaC-specific Organizations<\/summary>\n    \n    This policy targets organizations with names starting with <code>iac-*<\/code> and enforces a naming convention for their repositories. The repository names must begin with the environment (e.g., <code>`prod-*`<\/code>, <code>`test-*`<\/code>, <code>`staging-*`<\/code>).\n\n    <img src=\"\/assets\/images\/2025-01-09-7-cool-things-with-rulesets\/enforce-iac-repos-naming-convention.png\" alt=\"enforce iac repos naming convention\" \/>\n<\/details>\n\n<h2 id=\"wrapping-up-and-looking-ahead\">Wrapping Up and Looking Ahead<\/h2>\n\n<p>We\u2019ve explored how GitHub rulesets help streamline workflows, enforce policies, and ensure consistency across repositories and organizations. From blocking binary files to enforcing commit author patterns, these tools foster better collaboration and security.<\/p>\n\n<p>Like a Zen master refining their craft through meditation, the consistent application of these rules cultivates balance, focus, and discipline in your processes. Keep your practices sharp and your mind clear, and you\u2019ll master the art of streamlined, secure development.<\/p>\n\n<p>Like a Zen master refining their craft through meditation, the consistent application of these rules cultivates balance, focus, and discipline in your workflows. Keep your practices sharp and your mind clear, and you\u2019ll master the art of streamlined, secure development.<\/p>\n\n<p>Gassh\u014d \ud83d\ude4f<\/p>\n"},{"title":"Securing GitHub Actions workflows with Immutable Actions","link":{"@attributes":{"href":"https:\/\/ghsioux.github.io\/2024\/12\/10\/securing-workflow-immutable-actions"}},"updated":"2024-12-10T00:00:00+01:00","id":"https:\/\/ghsioux.github.io\/2024\/12\/10\/securing-workflow-immutable-actions","content":"<p><strong>Long time no see!<\/strong><\/p>\n\n<p>I\u2019ve been sharpening my skills in the DevSecOps peaks \u26f0\ufe0f\ud83c\udfd4\ufe0f\u26f0\ufe0f. Now, I\u2019m back stronger, ready for new quests\u2014hope you\u2019ve been practicing too.<\/p>\n\n<p>Recently, a customer posed an intriguing challenge: <strong>Could Immutable Actions disrupt the way workflows reference actions?<\/strong> This led me deep into the lore of GitHub Actions. The verdict? <strong>No worries<\/strong>. Why? Immutable actions wildcard versioning and resolution make it seamless.<\/p>\n\n<p>Before we dive into this enigma, let\u2019s set the stage: What are Immutable Actions? Why are they vital? And how do artifact attestations fit into the picture? Alright, ninja \ud83e\udd77, let\u2019s resume our journey.<\/p>\n\n<blockquote>\n  <p>\u26a0\ufe0f <strong>Note:<\/strong> At the time of writing, Immutable Actions are in <a href=\"https:\/\/github.com\/features\/preview\/immutable-actions\">limited public preview<\/a> and subject to change.<\/p>\n<\/blockquote>\n\n<h2 id=\"1---the-genesis-artifact-attestations\">1 - The Genesis: Artifact Attestations<\/h2>\n\n<p><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/actions\/security-for-github-actions\/using-artifact-attestations\/using-artifact-attestations-to-establish-provenance-for-builds\">Artifact attestations in GitHub<\/a> [<a href=\"https:\/\/github.blog\/security\/supply-chain-security\/introducing-npm-package-provenance\/\">1<\/a>] [<a href=\"https:\/\/github.blog\/security\/supply-chain-security\/configure-github-artifact-attestations-for-secure-cloud-native-delivery\/\">2<\/a>] enhance <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/code-security\/supply-chain-security\/understanding-your-software-supply-chain\/about-supply-chain-security\">supply chain security<\/a> by cryptographically linking <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/actions\/writing-workflows\/choosing-what-your-workflow-does\/storing-and-sharing-data-from-a-workflow#about-workflow-artifacts\">artifacts<\/a> such as binaries to their source code and build process. They ensure both integrity and provenance, reducing the risk of tampered or malicious software:<\/p>\n\n<ul>\n  <li>\n    <p><strong>Integrity:<\/strong> By using cryptographic signatures, artifact attestations ensure that the artifact remains untampered with since its creation. GitHub utilizes Sigstore for these cryptographic signatures.<\/p>\n  <\/li>\n  <li>\n    <p><strong>Origin:<\/strong> Provenance, or the origin of the artifact, is verified through detailed metadata contained in the attestations. This includes for instance the specific commit, the GitHub Actions workflow, and the build environment, allowing full traceability back to the original source. GitHub uses the <a href=\"https:\/\/slsa.dev\/spec\/v1.0\/provenance\">Provenance feature<\/a> from <a href=\"https:\/\/slsa.dev\/\">OpenSSF\u2019s SLSA<\/a> (Supply Chain Levels for Software Artifacts) framework to provide this.<\/p>\n  <\/li>\n<\/ul>\n\n<p>For developers and teams, this means greater confidence in the security of dependencies and reduced risk from compromised build environments. The following table compares the security implications of artifacts with and without cryptographic signatures, and with and without provenance metadata:<\/p>\n\n<table>\n  <thead>\n    <tr>\n      <th>\u00a0<\/th>\n      <th><strong>With Cryptographic Signature<\/strong><\/th>\n      <th><strong>Without Cryptographic Signature<\/strong><\/th>\n    <\/tr>\n  <\/thead>\n  <tbody>\n    <tr>\n      <td><strong>With Provenance Metadata<\/strong><\/td>\n      <td>\ud83d\udfe2 <strong>Secure<\/strong><br \/>- Full traceability.<br \/>- Artifact integrity assured.<br \/>- Minimal risk (if implemented correctly).<\/td>\n      <td>\ud83d\udfe1 <strong>Limited Security<\/strong><br \/>- Traceability available.<br \/>- Artifacts may be tampered post-build.<br \/>- Risks of distribution attacks (e.g., artifact substitution).<\/td>\n    <\/tr>\n    <tr>\n      <td><strong>Without Provenance Metadata<\/strong><\/td>\n      <td>\ud83d\udfe1 <strong>Limited Security<\/strong><br \/>- Artifact integrity assured.<br \/>- No traceability.<br \/>- Loss of reproducibility.<br \/>- Builds from unverified sources.<\/td>\n      <td>\ud83d\udd34 <strong>Insecure<\/strong><br \/>- No traceability or integrity assurance.<br \/>- High risk of malicious artifacts and insecure builds.<\/td>\n    <\/tr>\n  <\/tbody>\n<\/table>\n\n<p>As a last note, remember that attestations are only effective if <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/actions\/security-for-github-actions\/using-artifact-attestations\/using-artifact-attestations-to-establish-provenance-for-builds#verifying-artifact-attestations-with-the-github-cli\">verified<\/a>, making it crucial to validate signed artifacts, particularly for binaries, packages, and manifests.<\/p>\n\n<h2 id=\"2---the-next-step-immutable-actions\">2 - The Next Step: Immutable Actions<\/h2>\n\n<p>Now that we know what are artifact attestations, let\u2019s take these concepts a step further and apply them to <strong>GitHub Actions<\/strong>. Just like build artifacts, it\u2019s essential to ensure that the actions used in workflows are trustworthy and secure. The good news is that we can achieve this through <strong>Immutable Actions<\/strong>.<\/p>\n\n<p>Immutable Actions are a new feature in GitHub that ensures the actions used in CI\/CD pipelines are secured and untampered. Let\u2019s break down how Immutable Actions work with three essential features:<\/p>\n\n<ul>\n  <li>\n    <p><strong>Secure Publishing Flow<\/strong><br \/>\n  Immutable Actions are published through a secure process using an Actions token as part of a workflow run. This ensures that the action is firmly tied to its source repository. Furthermore, <strong>artifact attestations<\/strong> are generated to verify the publishing process, ensuring that actions are legitimate.<\/p>\n  <\/li>\n  <li>\n    <p><strong>Package and Tag Immutability<\/strong><br \/>\n  Once an action is published, it is served as a package from <a href=\"https:\/\/docs.github.com\/en\/packages\/working-with-a-github-packages-registry\/working-with-the-container-registry\">GHCR<\/a> and its version becomes immutable. This means that tags and branches can\u2019t be overwritten or changed to point to different artifacts. This feature guarantees that the action version remains consistent over time, protecting against tampering and unexpected changes.<\/p>\n  <\/li>\n  <li>\n    <p><strong>Locking Down Actions Resolution<\/strong><br \/>\n  With Immutable Actions, GitHub enforces strict <a href=\"https:\/\/semver.org\/\">semantic versioning<\/a> with automatic wildcard resolution (\u2726\u2726 see next section). This ensures that workflows use actions that have a stable and verifiable version. For instance, the action\u2019s reference cannot change to a different commit unless the version number reflects it. This prevents mutable references (like branches and tags) from altering the behavior of workflows unexpectedly.<\/p>\n  <\/li>\n<\/ul>\n\n<p>Let\u2019s explore how Immutable Actions compare to the mutable ones and how they mitigate common security risks:<\/p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Aspect<\/th>\n      <th>Before Immutable Actions<\/th>\n      <th>With Immutable Actions<\/th>\n    <\/tr>\n  <\/thead>\n  <tbody>\n    <tr>\n      <td><strong>Source &amp; Behavior<\/strong><\/td>\n      <td>Actions fetched <strong>as code<\/strong> from GitHub using mutable git tags, making them less traceable and prone to unexpected changes.<\/td>\n      <td>Actions served <strong>as packages<\/strong> from <code class=\"language-plaintext highlighter-rouge\">ghcr.io<\/code>, resolved with immutable package versions, ensuring better traceability and consistency.<\/td>\n    <\/tr>\n    <tr>\n      <td><strong>(Im)mutability<\/strong><\/td>\n      <td>Vulnerable to tag mutations, allowing potentially malicious code changes.<\/td>\n      <td>Secure resolution with immutable tags and verified publishing flow, preventing tampering.<\/td>\n    <\/tr>\n    <tr>\n      <td><strong>Versioning<\/strong><\/td>\n      <td>Wildcard versions (e.g. <code class=\"language-plaintext highlighter-rouge\">v1<\/code>) manually maintained, leading to inconsistencies.<\/td>\n      <td>Reliable resolution of wildcard versions to the latest matching package (e.g. <code class=\"language-plaintext highlighter-rouge\">v1 -&gt; 1.3.2<\/code>), eliminating versioning issues (\u2726\u2726 see next section).<\/td>\n    <\/tr>\n  <\/tbody>\n<\/table>\n\n<h2 id=\"3---a-note-on-versioning-and-resolution\">3 - A note on versioning and resolution<\/h2>\n\n<p>Before Immutable Actions, actions in workflows were referenced using mutable tags or branches, e.g.:<\/p>\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>uses: my-org\/my-action@v1       # tag\nuses: my-org\/my-action@v1.3.2   # tag\nuses: my-org\/my-action@main     # branch\n<\/code><\/pre><\/div><\/div>\n\n<p>While referencing by commit SHA (<code class=\"language-plaintext highlighter-rouge\">my-org\/my-action@f4b1...73aa<\/code>) was possible - and the most secure way since not mutable -  it was not an ideal solution from a user experience perspective due to its lack of flexibility.<\/p>\n\n<p>Immutable Actions introduce wildcard versioning to balance stability and flexibility in GitHub workflows. This features allows tag-like references such as <code class=\"language-plaintext highlighter-rouge\">v1.3<\/code> in workflows to automatically resolve to the latest immutable action package matching the semantic version <code class=\"language-plaintext highlighter-rouge\">1.3.z<\/code>. As a result, immutable actions in workflows can now be referenced either via their strict package version (e.g. <code class=\"language-plaintext highlighter-rouge\">my-org\/my-action@1.3.2<\/code>, note the absence of <code class=\"language-plaintext highlighter-rouge\">v<\/code> prefix), <strong>or<\/strong> via tag-like references potentially with wildcard versioning (e.g <code class=\"language-plaintext highlighter-rouge\">my-org\/my-action@v1.3<\/code>).<\/p>\n\n<p>The following diagram demonstrates how GitHub resolves wildcard references to the latest matching package version:<\/p>\n\n<p><img src=\"\/assets\/images\/2024-12-10-securing-workflow-immutable-actions\/wildcard-resolution.png\" alt=\"Wildcard resolution example\" title=\"Wildcard resolution example\" \/><\/p>\n\n<p>While wildcard versioning and resolution provides flexibility, it challenges the core principle of immutability. Immutable Actions ensure an action\u2019s content and behavior remain consistent, making dynamic changes from wildcard references potentially problematic. For example, if a workflow references <code class=\"language-plaintext highlighter-rouge\">v1<\/code>, it might unintentionally introduce behavior changes with a new minor or patch release, like moving from <code class=\"language-plaintext highlighter-rouge\">1.2<\/code> to <code class=\"language-plaintext highlighter-rouge\">1.3<\/code>. For maximum stability and immutability, it\u2019s recommended to pin actions to a specific version, such as <code class=\"language-plaintext highlighter-rouge\">1.3.2<\/code>.<\/p>\n\n<h2 id=\"4---practical-example\">4 - Practical Example<\/h2>\n\n<p>Enough theory, let\u2019s now see how to use Immutable Actions in practice. We\u2019ll use <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\">this demo repository<\/a> which has Immutable Actions enabled to showcase how they work. It contains a typical structure for a simple custom action written in JavaScript:<\/p>\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">index.js<\/code>: the action code (it just prints a message to the standard output);<\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">action.yml<\/code>: the action\u2019s metadata file;<\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">package.json<\/code>: the action\u2019s package file.<\/li>\n<\/ul>\n\n<p>In addition, we have <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/blob\/main\/.github\/workflows\/publish-immutable-actions.yml\">the <code class=\"language-plaintext highlighter-rouge\">publish-immutable-actions.yml<\/code> workflow file<\/a>, triggered when a new released is created to publish the immutable action:<\/p>\n\n<div class=\"language-yaml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s2\">\"<\/span><span class=\"s\">Publish<\/span><span class=\"nv\"> <\/span><span class=\"s\">Immutable<\/span><span class=\"nv\"> <\/span><span class=\"s\">Action<\/span><span class=\"nv\"> <\/span><span class=\"s\">Version\"<\/span>\n<span class=\"na\">on<\/span><span class=\"pi\">:<\/span>\n  <span class=\"na\">release<\/span><span class=\"pi\">:<\/span>\n    <span class=\"na\">types<\/span><span class=\"pi\">:<\/span> <span class=\"pi\">[<\/span><span class=\"nv\">created<\/span><span class=\"pi\">]<\/span>\n<span class=\"na\">jobs<\/span><span class=\"pi\">:<\/span>\n  <span class=\"na\">publish<\/span><span class=\"pi\">:<\/span>\n    <span class=\"na\">runs-on<\/span><span class=\"pi\">:<\/span> <span class=\"s\">ubuntu-latest<\/span>\n    <span class=\"na\">permissions<\/span><span class=\"pi\">:<\/span>\n      <span class=\"na\">contents<\/span><span class=\"pi\">:<\/span> <span class=\"s\">read<\/span>\n      <span class=\"na\">id-token<\/span><span class=\"pi\">:<\/span> <span class=\"s\">write<\/span>\n      <span class=\"na\">packages<\/span><span class=\"pi\">:<\/span> <span class=\"s\">write<\/span>\n    <span class=\"na\">steps<\/span><span class=\"pi\">:<\/span>\n      <span class=\"pi\">-<\/span> <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">Checking out<\/span>\n        <span class=\"na\">uses<\/span><span class=\"pi\">:<\/span> <span class=\"s\">actions\/checkout@v4<\/span>\n      <span class=\"pi\">-<\/span> <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">Publish<\/span>\n        <span class=\"na\">id<\/span><span class=\"pi\">:<\/span> <span class=\"s\">publish<\/span>\n        <span class=\"na\">uses<\/span><span class=\"pi\">:<\/span> <span class=\"s\">actions\/publish-immutable-action@0.0.1<\/span>\n        <span class=\"na\">with<\/span><span class=\"pi\">:<\/span>\n          <span class=\"na\">github-token<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ secrets.GITHUB_TOKEN }}<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<p>All the magic happens in <a href=\"https:\/\/github.com\/actions\/publish-immutable-action\">the <code class=\"language-plaintext highlighter-rouge\">publish-immutable-action<\/code> action<\/a>.<\/p>\n\n<p>I created and pushed <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/releases\/tag\/v1.0.0\">the tag <code class=\"language-plaintext highlighter-rouge\">v1.0.0<\/code><\/a>, created <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/releases\/tag\/v1.0.0\">a release<\/a> from this tag and the immutable action <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/actions\/runs\/12175417462\/job\/33959091043\">has been published accordingly<\/a> (you can see the attestation has been published too in the job\u2019s log). <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/pkgs\/container\/immutable-action-demo\/317337038?tag=1.0.0\">The corresponding package<\/a> in GHCR has the label <code class=\"language-plaintext highlighter-rouge\">Immutable<\/code>.<\/p>\n\n<p><img src=\"\/assets\/images\/2024-12-10-securing-workflow-immutable-actions\/immutable-action-package.png\" alt=\"Immutable action package version 1.0.0\" title=\"Immutable action package version 1.0.0\" \/><\/p>\n\n<p>I can verify the attestation of the immutable action using <a href=\"https:\/\/cli.github.com\/\">the GitHub CLI<\/a>:<\/p>\n<div class=\"language-bash highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"c\"># General verification<\/span>\n<span class=\"nv\">$ <\/span>gh attestation verify oci:\/\/ghcr.io\/ghsioux\/immutable-action-demo:1.0.0 <span class=\"nt\">--bundle-from-oci<\/span> <span class=\"nt\">--owner<\/span> ghsioux\nLoaded digest sha256:59ec50c64e24213772a37b17715946a133de7b1bef33885a49bf691ea03f5ae5 <span class=\"k\">for <\/span>oci:\/\/ghcr.io\/ghsioux\/immutable-action-demo:1.0.0\nLoaded 1 attestation from oci:\/\/ghcr.io\/ghsioux\/immutable-action-demo:1.0.0\n\u2713 Verification succeeded!\n\nsha256:59ec50c64e24213772a37b17715946a133de7b1bef33885a49bf691ea03f5ae5 was attested by:\nREPO                           PREDICATE_TYPE                  WORKFLOW\nghsioux\/immutable-action-demo  https:\/\/slsa.dev\/provenance\/v1  .github\/workflows\/publish-immutable-actions.yml@refs\/tags\/v1.0.0\n\n<span class=\"c\"># Retrieve the associated commit<\/span>\n<span class=\"nv\">$ <\/span>gh attestation verify oci:\/\/ghcr.io\/ghsioux\/immutable-action-demo:1.0.0 <span class=\"nt\">--bundle-from-oci<\/span> <span class=\"nt\">--owner<\/span> ghsioux <span class=\"nt\">--format<\/span> json | jq <span class=\"s1\">'.[0].verificationResult.statement.predicate.buildDefinition.resolvedDependencies[0].digest.gitCommit'<\/span>\n<span class=\"s2\">\"653ed94bd9425e1e50c8de8002f16bbe22e84f38\"<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<p>I\u2019ve then <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/commit\/f4b1295e2051fd43a5085dd9514f5ae823ce73aa\">updated the action code<\/a> to print a new message and <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/actions\/runs\/12175547252\">published a new version <code class=\"language-plaintext highlighter-rouge\">1.0.1<\/code><\/a> of the immutable action following the same process.<\/p>\n\n<p>Let\u2019s now test the action with <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/blob\/main\/.github\/workflows\/test-immutable-action.yml\">the following workflow<\/a>:<\/p>\n<div class=\"language-yaml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s2\">\"<\/span><span class=\"s\">Test<\/span><span class=\"nv\"> <\/span><span class=\"s\">Immutable<\/span><span class=\"nv\"> <\/span><span class=\"s\">Action\"<\/span>\n<span class=\"na\">on<\/span><span class=\"pi\">:<\/span>\n  <span class=\"na\">workflow_dispatch<\/span><span class=\"pi\">:<\/span>\n<span class=\"na\">jobs<\/span><span class=\"pi\">:<\/span>\n  <span class=\"na\">publish<\/span><span class=\"pi\">:<\/span>\n    <span class=\"na\">runs-on<\/span><span class=\"pi\">:<\/span> <span class=\"s\">ubuntu-latest<\/span>\n    <span class=\"na\">steps<\/span><span class=\"pi\">:<\/span>\n      <span class=\"pi\">-<\/span> <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">Test immutable action (strict SemVer)<\/span> <span class=\"c1\"># Using a specific immutable package version<\/span>\n        <span class=\"na\">uses<\/span><span class=\"pi\">:<\/span> <span class=\"s\">ghsioux\/immutable-action-demo@1.0.0<\/span> \n        <span class=\"c1\"># Resolves directly to the immutable action package version 1.0.0,<\/span>\n        <span class=\"c1\"># ensuring the exact behavior of the action as defined at that version.<\/span>\n\n      <span class=\"pi\">-<\/span> <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">Test tag resolution to package version (full tag)<\/span> <span class=\"c1\"># Resolves a tag to the corresponding package version<\/span>\n        <span class=\"na\">uses<\/span><span class=\"pi\">:<\/span> <span class=\"s\">ghsioux\/immutable-action-demo@v1.0.0<\/span>\n        <span class=\"c1\"># The tag v1.0.0 resolves to the immutable action package version 1.0.0.<\/span>\n        <span class=\"c1\"># This verifies that full tags correctly map to their corresponding immutable packages.<\/span>\n\n      <span class=\"pi\">-<\/span> <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">Test tag resolution to package version (wildcard versioning patch version)<\/span>\n        <span class=\"na\">uses<\/span><span class=\"pi\">:<\/span> <span class=\"s\">ghsioux\/immutable-action-demo@v1.0<\/span>\n        <span class=\"c1\"># The tag v1.0 resolves to the latest immutable action package matching version 1.0.x.<\/span>\n        <span class=\"c1\"># This tests the patch-level wildcard resolution in Immutable Actions.<\/span>\n\n      <span class=\"pi\">-<\/span> <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">Test tag resolution to package version (wildcard versioning minor version)<\/span>\n        <span class=\"na\">uses<\/span><span class=\"pi\">:<\/span> <span class=\"s\">ghsioux\/immutable-action-demo@v1<\/span>\n        <span class=\"c1\"># The tag v1 resolves to the latest immutable action package matching version 1.x.y.<\/span>\n        <span class=\"c1\"># This tests the minor-level wildcard resolution in Immutable Actions.<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<p>In <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/actions\/runs\/12175629284\/job\/33959726210\">the workflow logs<\/a>, we can see the following sequence of printed messages:<\/p>\n<div class=\"language-bash highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>Hello immutable shinobi!\nHello immutable shinobi!\nGoodbye immutable shinobi!\nGoodbye immutable shinobi!\n<\/code><\/pre><\/div><\/div>\n\n<p>Proving the action has been correctly resolved from tag to package version, supporting also wildcard versioning (<code class=\"language-plaintext highlighter-rouge\">v1<\/code> and <code class=\"language-plaintext highlighter-rouge\">v1.0<\/code> tags both resolving to action package version <code class=\"language-plaintext highlighter-rouge\">1.0.1<\/code>).<\/p>\n\n<p>That\u2019s nice. Now let\u2019s test some corner cases. What if I create <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/releases\/tag\/v1.0.2\">a tag <code class=\"language-plaintext highlighter-rouge\">v1.0.2<\/code><\/a> without publishing a corresponding immutable action and try to use it <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/blob\/231b99f91e2507a977f663da70404836f7064be3\/.github\/workflows\/test-immutable-action-tag-without-release.yml\">in a workflow<\/a>? As expected, that simply <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/actions\/runs\/12176024772\/job\/33960889984\">does not work<\/a> because there is no immutable action matching the version <code class=\"language-plaintext highlighter-rouge\">1.0.2<\/code>:<\/p>\n\n<p><img src=\"\/assets\/images\/2024-12-10-securing-workflow-immutable-actions\/resolution-error.png\" alt=\"Action resolution error\" title=\"Action resolution error\" \/><\/p>\n\n<p>Now let\u2019s tackle immutability. I\u2019ve initially created a new tag <code class=\"language-plaintext highlighter-rouge\">v1.0.3<\/code> from <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/commit\/231b99f91e2507a977f663da70404836f7064be3\">commit 231b99f<\/a>  and <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/actions\/runs\/12176234738\">published<\/a> the corresponding <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/pkgs\/container\/immutable-action-demo\/317366598?tag=1.0.3\">immutable action <code class=\"language-plaintext highlighter-rouge\">1.0.3<\/code><\/a>. I then updated the code of the action (<a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/commit\/be580c03ebd9ba926f6bdfe516b6635ea9f240c3\">commit be580c03<\/a>) and made the remote tag <code class=\"language-plaintext highlighter-rouge\">v1.0.3<\/code> to point to this new commit. I removed the original <code class=\"language-plaintext highlighter-rouge\">v1.0.3<\/code> release, created it again, and guess what? Trying to create a new immutable action with that same tag <a href=\"https:\/\/github.com\/ghsioux\/immutable-action-demo\/actions\/runs\/12176310609\/job\/33961788301\">failed<\/a> with the error:<\/p>\n\n<p><img src=\"\/assets\/images\/2024-12-10-securing-workflow-immutable-actions\/publish-error.png\" alt=\"Action publish error\" title=\"Action publish error\" \/><\/p>\n\n<h2 id=\"5---conclusion\">5 - Conclusion<\/h2>\n\n<p>In this journey, we\u2019ve explored how Immutable Actions and artifact attestations fortify GitHub Actions workflows. By cryptographically signing actions and verifying their provenance, we can enhance the security of CI\/CD pipelines, bolstering the overall supply chain\u2019s integrity.<\/p>\n\n<p>But this is just the beginning. Immutable Actions lay the groundwork for a more robust future in DevSecOps. By adopting these practices, you not only protect your workflows but also contribute to a more secure ecosystem for everyone.<\/p>\n\n<p>In the dojo, we learn the value of collaboration. A big shoutout to the amazing team that helped unravel the inner workings of Immutable Actions: <a href=\"https:\/\/github.com\/tinaheidinger\">@tinaheidinger<\/a>, <a href=\"https:\/\/github.com\/thyeggman\">@thyeggman<\/a>, <a href=\"https:\/\/github.com\/konradpabjan\">@konradpabjan<\/a>, <a href=\"https:\/\/github.com\/conorsloan\">@conorsloan<\/a>, <a href=\"https:\/\/github.com\/jcambass\">@jcambass<\/a> and <a href=\"https:\/\/github.com\/steve-glass\">@steve-glass<\/a>.<\/p>\n\n<p>Stay vigilant, and keep your workflows secure, shinobi! \ud83e\udd77<\/p>\n\n<p>Gassh\u014d \ud83d\ude4f<\/p>\n"},{"title":"Customizing GitHub EMU Provisioning Mappings in Azure","link":{"@attributes":{"href":"https:\/\/ghsioux.github.io\/2024\/01\/23\/emu-mappings-manipulation"}},"updated":"2024-01-23T00:00:00+01:00","id":"https:\/\/ghsioux.github.io\/2024\/01\/23\/emu-mappings-manipulation","content":"<p>As an EMU (<a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/admin\/managing-iam\/understanding-iam-for-enterprises\/about-enterprise-managed-users\">Enterprise Managed Users<\/a>) administrator, you may have encountered challenges when provisioning users, especially when dealing with <strong>username length limitations<\/strong>. GitHub imposes a strict <strong>39-character limit<\/strong> on usernames for EMU, which can clash with long naming conventions in your IdP (Identity Provider).<\/p>\n\n<p>In this post, I\u2019ll show you how to customize provisioning mappings in Azure Entra ID to handle such scenarios, focusing on the username limit and how we can use <strong>expression mappings<\/strong> to create compliant usernames.<\/p>\n\n<h2 id=\"1---emu-and-user-provisioning\">1 - EMU and User Provisioning<\/h2>\n\n<p>GitHub Enterprise Managed Users (EMU) is a feature that allows organizations to manage user accounts and access within GitHub, all through an Identity Provider (IdP). This allows your organization to provision, update, and decommission GitHub users automatically based on changes in your IdP, like Azure AD, Okta, or PingFederate.<\/p>\n\n<p>User provisioning involves syncing user data (like usernames, email addresses, and roles) from your IdP to GitHub. This is automated to ensure that when users join, change roles, or leave your organization, their GitHub accounts are created, updated, or deleted accordingly. Under the hood, this is standardized through the <a href=\"https:\/\/scim.cloud\/\">SCIM (System for Cross-domain Identity Management)<\/a> specification.<\/p>\n\n<p>A core aspect of this process is provisioning mappings, which define how attributes from your IdP map to <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/rest\/enterprise-admin\/scim?apiVersion=2022-11-28#supported-scim-user-attributes\">GitHub\u2019s required SCIM properties<\/a>. For example, Azure\u2019s <code class=\"language-plaintext highlighter-rouge\">userPrincipalName<\/code> (UPN) field may need to map to GitHub\u2019s <code class=\"language-plaintext highlighter-rouge\">userName<\/code> SCIM attribute. When default mappings fall short\u2014like exceeding the username character limit\u2014custom mappings come to the rescue.<\/p>\n\n<h2 id=\"2---handling-username-length-limitation\">2 - Handling Username Length Limitation<\/h2>\n\n<p>When using Azure Entra ID as the identity provider for EMU, the default mapping for the GitHub usernames will be the following:<\/p>\n\n<p><img src=\"\/assets\/images\/2024-01-23-emu-mappings-manipulation\/defaultmapping.png\" alt=\"default userName mapping\" title=\"default userName mapping\" \/><\/p>\n\n<p>Here\u2019s the crux of the issue: GitHub usernames must include your <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/admin\/managing-iam\/iam-configuration-reference\/username-considerations-for-external-authentication#shortcodes-on-githubcom\">EMU shortcode<\/a> suffix, leaving less room for the main portion of the username. For instance, a user\u2019s <code class=\"language-plaintext highlighter-rouge\">userPrincipalName<\/code> like <code class=\"language-plaintext highlighter-rouge\">firstname-lastname-external<\/code> might exceed the 39-character cap when the shortcode is added.<\/p>\n\n<p>As a reminder, the shortcode is chosen when you create an enterprise with managed users on GitHub.com to represent your enterprise. For example, if the shortcode is <code class=\"language-plaintext highlighter-rouge\">octo<\/code>, a provisioned user might have a GitHub username like <code class=\"language-plaintext highlighter-rouge\">mona-cat_octo<\/code> where <code class=\"language-plaintext highlighter-rouge\">mona-cat<\/code> is derived from the identity provider during provisioning.<\/p>\n\n<p>Azure Entra ID provides a straightforward solution using the <a href=\"https:\/\/learn.microsoft.com\/en-us\/entra\/identity\/app-provisioning\/functions-for-customizing-application-data#left\"><code class=\"language-plaintext highlighter-rouge\">Left()<\/code> function<\/a>, which trims strings to a specific length:<\/p>\n\n<div class=\"language-java highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nc\">Left<\/span><span class=\"o\">(<\/span><span class=\"n\">text<\/span><span class=\"o\">,<\/span> <span class=\"n\">number_of_characters<\/span><span class=\"o\">)<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<p>With:<\/p>\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">text<\/code>: The string you want to shorten (in this case, <code class=\"language-plaintext highlighter-rouge\">userPrincipalName<\/code>).<\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">number_of_characters<\/code>: The number of characters to extract.<\/li>\n<\/ul>\n\n<p>For example, if your shortcode plus the <code class=\"language-plaintext highlighter-rouge\">_<\/code> is 5 characters (e.g. <code class=\"language-plaintext highlighter-rouge\">_octo<\/code>), you can allow up to 34 characters for the UPN:<\/p>\n\n<div class=\"language-java highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nc\">Left<\/span><span class=\"o\">([<\/span><span class=\"n\">userPrincipalName<\/span><span class=\"o\">],<\/span> <span class=\"mi\">34<\/span><span class=\"o\">)<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<p>This ensures the entire username, including the shortcode, stays within GitHub\u2019s limit. You can configure this as an expression mapping in Azure Entra ID to automate the transformation.<\/p>\n\n<p><img src=\"\/assets\/images\/2024-01-23-emu-mappings-manipulation\/leftmapping.png\" alt=\"custom userName mapping with Left() expression\" title=\"custom userName mapping with Left() expression\" \/><\/p>\n\n<h2 id=\"3---broadening-the-scope\">3 - Broadening the Scope<\/h2>\n\n<p>While truncating usernames is a common use-case, there are other scenarios where provisioning mappings may need customization. For example, you might want to:<\/p>\n\n<ul>\n  <li>\n    <p><strong>Use a custom field for the usernames<\/strong>: Companies might have specific fields in their IdP - such as <code class=\"language-plaintext highlighter-rouge\">employeeID<\/code> - that better suit their GitHub\u2019s username strategy. By mapping these fields, you can ensure usernames are compliant without manual intervention.<\/p>\n  <\/li>\n  <li>\n    <p><strong>Normalize email addresses<\/strong>: Normalize the emails attribute to ensure a consistent domain suffix for all users. For instance, if your organization uses multiple domains, you might standardize email addresses so that all users appear with the same domain in GitHub (e.g., <code class=\"language-plaintext highlighter-rouge\">john.doe@sub.example.com<\/code> becomes <code class=\"language-plaintext highlighter-rouge\">john.doe@example.com<\/code>).<\/p>\n  <\/li>\n  <li>\n    <p><strong>Customize display names<\/strong>: Use the <code class=\"language-plaintext highlighter-rouge\">name.givenName<\/code> and <code class=\"language-plaintext highlighter-rouge\">name.familyName<\/code> attributes to create a more standardized or localized display name format for users in GitHub. For example, if your organization prefers full names in a \u201cLastName, FirstName\u201d format, you could map and combine these attributes accordingly.<\/p>\n  <\/li>\n<\/ul>\n\n<h2 id=\"4---wrapping-up-and-next-steps\">4 - Wrapping Up and Next Steps<\/h2>\n\n<p>We\u2019ve seen how to tackle GitHub\u2019s username length limitations by customizing provisioning mappings in Azure Entra ID. By leveraging expression mappings like <code class=\"language-plaintext highlighter-rouge\">Left<\/code>, you can ensure usernames stay compliant while maintaining automation and consistency. This approach can also be extended to normalize other attributes like email addresses or display names, adapting the provisioning process to fit your organizational needs.<\/p>\n\n<p>What if you\u2019re not using Entra ID? No worries\u2014GitHub supports various identity providers, including <strong><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/admin\/managing-iam\/provisioning-user-accounts-with-scim\/configuring-scim-provisioning-with-okta\">Okta<\/a><\/strong> and <strong><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/admin\/managing-iam\/provisioning-user-accounts-with-scim\/configuring-authentication-and-provisioning-with-pingfederate\">PingFederate<\/a><\/strong>, which offer similar customization options for SCIM attribute mappings. Additionally, for other IdPs, you can leverage GitHub\u2019s <strong><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/admin\/managing-iam\/provisioning-user-accounts-with-scim\/configuring-scim-provisioning-for-users#configuring-provisioning-for-other-identity-management-systems\">Open SCIM Configuration<\/a><\/strong> and its <strong><a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/rest\/enterprise-admin\/scim?apiVersion=2022-11-28\">SCIM API<\/a><\/strong> to build fully tailored integrations. These tools provide the flexibility to manage provisioning while adhering to GitHub\u2019s constraints, no matter your setup.<\/p>\n\n<p>That\u2019s it for today, ninjas \u2014 time to resume practice in the Cloud Dojo.<\/p>\n\n<p>Gassh\u014d \ud83d\ude4f<\/p>\n"},{"title":"Using GitHub Actions for multi-clouds deployment with OIDC and rollback support","link":{"@attributes":{"href":"https:\/\/ghsioux.github.io\/2023\/04\/05\/multi-clouds-deployment"}},"updated":"2023-04-05T00:00:00+02:00","id":"https:\/\/ghsioux.github.io\/2023\/04\/05\/multi-clouds-deployment","content":"<p>That\u2019s it ninjas, spring has arrived, birds are singing and beautiful clouds adorn the sky. It make me remember about these old stories, where some mountain monks could touch multiple of them at once.<\/p>\n\n<p>Today, we\u2019re going to do the same thing, but with different clouds. Let\u2019s use our GitHub Actions katas to deploy an application to Azure, AWS and GCP ! \u2601\ufe0f\u2601\ufe0f\u2601\ufe0f<\/p>\n\n<h2 id=\"1---general-view\">1 - General View<\/h2>\n\n<p>We\u2019ll deploy the <a href=\"https:\/\/github.com\/spring-projects\/spring-petclinic\">Spring Petclinic sample application<\/a> as a container application in the cloud, and this is the <a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\">fork repository<\/a> where we\u2019ll work on. The <a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.github\/workflows\/multi-cloud-deployment.yml\">\u201c\ud83d\ude80 Multi-cloud deployment\u201d<\/a> is the main workflow from where the deployment starts. The overall process is as follows:<\/p>\n\n<ol>\n  <li>Build the application using Maven to generate a JAR file <a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.github\/workflows\/multi-cloud-deployment.yml#L45-L72\">(link to code)<\/a>;<\/li>\n  <li>Build and push a container image ready to run this JAR file <a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.github\/workflows\/multi-cloud-deployment.yml#L74-L111\">(link to code)<\/a>;<\/li>\n  <li>Run the container image on each cloud provider <a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.github\/workflows\/multi-cloud-deployment.yml#L113-L177\">(link to code)<\/a>.<\/li>\n<\/ol>\n\n<p>This dojo session will mainly focus on the last step and some of its specificities. If you\u2019ve followed its link, you\u2019ll have noticed that three <a href=\"https:\/\/docs.github.com\/en\/actions\/using-workflows\/reusing-workflows\">reusable workflows<\/a> - one per cloud provider - are called to this end. This is because I will likely use them in future projects, as deploying container applications to the cloud is a common task. Also, this is a nice way to keep the main workflow as simple as possible.<\/p>\n\n<p>Overall, the deployment will have the following properties:<\/p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Properties<\/th>\n      <th>How<\/th>\n    <\/tr>\n  <\/thead>\n  <tbody>\n    <tr>\n      <td><strong>Automated<\/strong><\/td>\n      <td>The deployment will be performed with GitHub Actions.<\/td>\n    <\/tr>\n    <tr>\n      <td><strong>Versioned<\/strong><\/td>\n      <td>The workflow will be triggered when <a href=\"https:\/\/docs.github.com\/en\/repositories\/releasing-projects-on-github\/managing-releases-in-a-repository#creating-a-release\">a new release is published<\/a>, or manually on <a href=\"https:\/\/docs.github.com\/en\/rest\/git\/tags?apiVersion=2022-11-28#about-git-tags\">specific tags<\/a>. But not with every tags \ud83e\udd77\ud83d\udc47<\/td>\n    <\/tr>\n    <tr>\n      <td><strong>Protected<\/strong><\/td>\n      <td>The protection is threefold: <br \/><ul class=\"table-list\"><li><strong>Who can deploy?<\/strong> Only repository admins; <\/li><li> <strong>What can be deployed?<\/strong> Only tags matching the regular expression <code class=\"language-plaintext highlighter-rouge\">v*<\/code> (and associated releases since releases are based on tags); <\/li><li> <strong>Where to deploy?<\/strong> Only on three specific, protected GitHub environments (named <code class=\"language-plaintext highlighter-rouge\">aws<\/code>, <code class=\"language-plaintext highlighter-rouge\">azure<\/code> and <code class=\"language-plaintext highlighter-rouge\">gcp<\/code> for the cloud providers they\u2019ll respectively target).<\/li><\/ul><\/td>\n    <\/tr>\n    <tr>\n      <td><strong>Passwordless<\/strong><\/td>\n      <td>Authentication to the cloud providers is done using <a href=\"https:\/\/openid.net\/connect\/\">the OpenID Connect standard<\/a>, hence no need to manage any password.<\/td>\n    <\/tr>\n    <tr>\n      <td><strong>Geo-distributed<\/strong><\/td>\n      <td>The application will be deployed on three different geographical locations: <a href=\"https:\/\/docs.aws.amazon.com\/AWSEC2\/latest\/UserGuide\/using-regions-availability-zones.html#concepts-regions\"><code class=\"language-plaintext highlighter-rouge\">ap-southeast-1<\/code> for AWS<\/a>, <a href=\"https:\/\/azure.microsoft.com\/en-us\/explore\/global-infrastructure\/geographies\/#geographies\"><code class=\"language-plaintext highlighter-rouge\">east us<\/code> for Azure<\/a> and <a href=\"https:\/\/cloud.google.com\/compute\/docs\/regions-zones#available\"><code class=\"language-plaintext highlighter-rouge\">europe-west1<\/code> for GCP<\/a>.<\/td>\n    <\/tr>\n  <\/tbody>\n<\/table>\n\n<h2 id=\"2---shaping-the-clouds\">2 - Shaping the clouds<\/h2>\n\n<p>Each of the cloud providers has its own way(s) to deploy container applications, and provides the associated GitHub Actions to do it. Here is a quick recap of the ones I\u2019ve used:<\/p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Cloud provider<\/th>\n      <th>Container Service<\/th>\n      <th>GitHub Actions<\/th>\n    <\/tr>\n  <\/thead>\n  <tbody>\n    <tr>\n      <td>Amazon Web Services<\/td>\n      <td><a href=\"https:\/\/aws.amazon.com\/ecs\/\">Elastic Container Service<\/a><\/td>\n      <td><ul class=\"table-list\"><li><a href=\"https:\/\/github.com\/marketplace\/actions\/amazon-ecs-render-task-definition-action-for-github-actions\">aws-actions\/amazon-ecs-render-task-definition<\/a> <\/li><li><a href=\"https:\/\/github.com\/marketplace\/actions\/amazon-ecs-deploy-task-definition-action-for-github-actions\">aws-actions\/amazon-ecs-deploy-task-definition<\/a> <\/li><\/ul><\/td>\n    <\/tr>\n    <tr>\n      <td>Microsoft Azure<\/td>\n      <td><a href=\"https:\/\/azure.microsoft.com\/en-us\/services\/container-instances\/\">Azure Container Instances<\/a><\/td>\n      <td><a href=\"https:\/\/github.com\/marketplace\/actions\/deploy-to-azure-container-instances\">Azure\/aci-deploy<\/a><\/td>\n    <\/tr>\n    <tr>\n      <td>Google Cloud Platform<\/td>\n      <td><a href=\"https:\/\/cloud.google.com\/run\">Cloud Run<\/a><\/td>\n      <td><a href=\"https:\/\/github.com\/marketplace\/actions\/deploy-to-cloud-run\">google-github-actions\/deploy-cloudrun<\/a><\/td>\n    <\/tr>\n  <\/tbody>\n<\/table>\n\n<p>Before using these actions in our workflows, we have to set up the cloud infrastructures first. With the aim of keeping this scroll as short as possible, I\u2019ve detailed this process in the <a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/tree\/main\/docs\/infra-setup\"><code class=\"language-plaintext highlighter-rouge\">doc\/infra-setup<\/code> folder<\/a> and all the CLI commands are provided. You can also have a look at <a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/README.md\">the quickstart<\/a> to get an overall picture.<\/p>\n\n<blockquote>\n  <p>\ud83d\udca1 <strong>Bonus!<\/strong> If you want to try it, but don\u2019t want to install the CLI tools on your own machine, there is <a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.devcontainer\/devcontainer.json\">a codespaces setup<\/a> ready to be used for that \u2728<\/p>\n<\/blockquote>\n\n<p>Once it\u2019s done, we\u2019ll use these actions in our reusable workflows to deploy the container application:<\/p>\n\n<ul>\n  <li>For Amazon (<a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.github\/workflows\/deploy-to-aws-ecs.yml#L68-L83\">link to step<\/a>):\n    <div class=\"language-yaml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>    <span class=\"pi\">-<\/span> <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">Prepare the Amazon ECS task definition to use our container image<\/span> \n      <span class=\"na\">id<\/span><span class=\"pi\">:<\/span> <span class=\"s\">task-def<\/span>\n      <span class=\"na\">uses<\/span><span class=\"pi\">:<\/span> <span class=\"s\">aws-actions\/amazon-ecs-render-task-definition@v1<\/span>\n      <span class=\"na\">with<\/span><span class=\"pi\">:<\/span>\n        <span class=\"na\">task-definition<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.ecs-task-definition }}<\/span>\n        <span class=\"na\">container-name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.container-name }}<\/span>\n        <span class=\"na\">image<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.container-image }}<\/span>\n\n    <span class=\"pi\">-<\/span> <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">Deploy the Amazon ECS task definition (i.e. deploy the container app)<\/span>\n      <span class=\"na\">id<\/span><span class=\"pi\">:<\/span> <span class=\"s\">deploy_task<\/span>\n      <span class=\"na\">uses<\/span><span class=\"pi\">:<\/span> <span class=\"s\">aws-actions\/amazon-ecs-deploy-task-definition@v1<\/span>\n      <span class=\"na\">with<\/span><span class=\"pi\">:<\/span>\n        <span class=\"na\">task-definition<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ steps.task-def.outputs.task-definition }}<\/span>\n        <span class=\"na\">service<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.ecs-service }}<\/span>\n        <span class=\"na\">cluster<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.ecs-cluster }}<\/span>\n        <span class=\"na\">wait-for-service-stability<\/span><span class=\"pi\">:<\/span> <span class=\"no\">true<\/span>\n<\/code><\/pre><\/div>    <\/div>\n  <\/li>\n  <li>For Azure (<a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.github\/workflows\/deploy-to-azure-aci.yml#L63-L71\">link to step<\/a>):\n    <div class=\"language-yaml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>    <span class=\"pi\">-<\/span> <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s1\">'<\/span><span class=\"s\">Deploy<\/span><span class=\"nv\"> <\/span><span class=\"s\">to<\/span><span class=\"nv\"> <\/span><span class=\"s\">Azure<\/span><span class=\"nv\"> <\/span><span class=\"s\">Container<\/span><span class=\"nv\"> <\/span><span class=\"s\">Instances'<\/span>\n      <span class=\"na\">uses<\/span><span class=\"pi\">:<\/span> <span class=\"s1\">'<\/span><span class=\"s\">azure\/aci-deploy@v1'<\/span>\n      <span class=\"na\">with<\/span><span class=\"pi\">:<\/span>\n        <span class=\"na\">resource-group<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.resource-group }}<\/span>\n        <span class=\"na\">dns-name-label<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.deployment-url-prefix }}<\/span>\n        <span class=\"na\">image<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.container-image }}<\/span>\n        <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.deployment-name }}<\/span>\n        <span class=\"na\">location<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.location }}<\/span>\n        <span class=\"na\">ports<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.ports }}<\/span>\n<\/code><\/pre><\/div>    <\/div>\n  <\/li>\n  <li>For GCP (<a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.github\/workflows\/deploy-to-gcp-cloudrun.yml#L85-L92\">link to step<\/a>):\n    <div class=\"language-yaml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>    <span class=\"pi\">-<\/span> <span class=\"na\">id<\/span><span class=\"pi\">:<\/span> <span class=\"s1\">'<\/span><span class=\"s\">deploy'<\/span>\n      <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s1\">'<\/span><span class=\"s\">Deploy<\/span><span class=\"nv\"> <\/span><span class=\"s\">the<\/span><span class=\"nv\"> <\/span><span class=\"s\">image<\/span><span class=\"nv\"> <\/span><span class=\"s\">to<\/span><span class=\"nv\"> <\/span><span class=\"s\">Google<\/span><span class=\"nv\"> <\/span><span class=\"s\">Cloud<\/span><span class=\"nv\"> <\/span><span class=\"s\">Run'<\/span>\n      <span class=\"na\">uses<\/span><span class=\"pi\">:<\/span> <span class=\"s1\">'<\/span><span class=\"s\">google-github-actions\/deploy-cloudrun@v1'<\/span>\n      <span class=\"na\">with<\/span><span class=\"pi\">:<\/span>\n        <span class=\"na\">service<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.cloudrun-service }}<\/span>\n        <span class=\"na\">image<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.push-to-gar == <\/span><span class=\"no\">true<\/span><span class=\"s\"> &amp;&amp; inputs.gar-target-image || inputs.container-image }}<\/span>\n        <span class=\"na\">region<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.region }}<\/span>\n        <span class=\"na\">flags<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.flags }}<\/span>\n<\/code><\/pre><\/div>    <\/div>\n  <\/li>\n<\/ul>\n\n<p>You can observe that these workflows are called with different regions <a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.github\/workflows\/multi-cloud-deployment.yml#L130\">[1]<\/a> <a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.github\/workflows\/multi-cloud-deployment.yml#L152\">[2]<\/a> <a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.github\/workflows\/multi-cloud-deployment.yml#L173\">[3]<\/a> for each cloud provider, hence making the deployment <strong>geo-distributed<\/strong>. This is a good practice to ensure high availability and to reduce the risk of downtime. And this is by the way just one of the benefits of the multi-cloud approach.<\/p>\n\n<h2 id=\"3---oidc-in-actions\">3 - OIDC in Actions<\/h2>\n\n<p>So the clouds are ready and we know exactly how we\u2019ll deploy our application. That\u2019s neat, but we still have to authenticate beforehand in order to proceed. When it comes to authenticate to cloud providers in GitHub Actions, two good practices pop up:<\/p>\n<ul>\n  <li><strong>Avoid using passwords<\/strong> as they are hard to rotate and can be leaked;<\/li>\n  <li><strong>Use service accounts<\/strong> instead of personal accounts, as they provide better security and control over permissions and access to cloud resources.<\/li>\n<\/ul>\n\n<p>And guess what? This is exactly what we gonna do here: we\u2019ll use a service account for each cloud provider, and we\u2019ll configure them to authenticate using the OpenID Connect standard.<\/p>\n\n<p>Similarly to what we did for the cloud infrastructures, I\u2019ve detailed this process in the <a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/tree\/main\/docs\/oidc-setup\"><code class=\"language-plaintext highlighter-rouge\">doc\/oidc-setup<\/code> folder<\/a> and the following table summarizes what has been used to this end:<\/p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Cloud provider<\/th>\n      <th>Service account construct<\/th>\n      <th>OIDC implementation<\/th>\n      <th>GitHub Action<\/th>\n    <\/tr>\n  <\/thead>\n  <tbody>\n    <tr>\n      <td>Amazon Web Services<\/td>\n      <td><a href=\"https:\/\/docs.aws.amazon.com\/IAM\/latest\/UserGuide\/id_roles.html\">IAM role<\/a><\/td>\n      <td><a href=\"https:\/\/docs.aws.amazon.com\/IAM\/latest\/UserGuide\/id_roles_providers_create_oidc.html\">OIDC identity provider<\/a><\/td>\n      <td><a href=\"https:\/\/github.com\/marketplace\/actions\/configure-aws-credentials-for-github-actions\">aws-actions\/configure-aws-credentials<\/a><\/td>\n    <\/tr>\n    <tr>\n      <td>Microsoft Azure<\/td>\n      <td><a href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/azure\/create-azure-service-principal-azureps?view=azps-9.5.0\">Service principal<\/a><\/td>\n      <td><a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/active-directory\/workload-identities\/workload-identity-federation?source=recommendations\">Workload identity federation<\/a><\/td>\n      <td><a href=\"https:\/\/github.com\/marketplace\/actions\/azure-login\">Azure\/login<\/a><\/td>\n    <\/tr>\n    <tr>\n      <td>Google Cloud Platform<\/td>\n      <td><a href=\"https:\/\/cloud.google.com\/iam\/docs\/service-account-overview\">Service account<\/a><\/td>\n      <td><a href=\"https:\/\/cloud.google.com\/iam\/docs\/workload-identity-federation\">Workload identity federation<\/a><\/td>\n      <td><a href=\"https:\/\/github.com\/marketplace\/actions\/authenticate-to-google-cloud\">google-github-actions\/auth<\/a><\/td>\n    <\/tr>\n  <\/tbody>\n<\/table>\n\n<p>Once everything is set up, we can authenticate to the cloud providers using OIDC in our reusable workflows:<\/p>\n\n<ul>\n  <li>For AWS (<a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.github\/workflows\/deploy-to-aws-ecs.yml#L61-L66\">link to step<\/a>):\n    <div class=\"language-yaml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>    <span class=\"pi\">-<\/span> <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">Configure AWS credentials using OIDC<\/span>\n      <span class=\"na\">uses<\/span><span class=\"pi\">:<\/span> <span class=\"s\">aws-actions\/configure-aws-credentials@v2<\/span>\n      <span class=\"na\">with<\/span><span class=\"pi\">:<\/span>\n        <span class=\"na\">role-to-assume<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ secrets.oidc-role-to-assume }}<\/span>\n        <span class=\"na\">role-session-name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">workflowrolesession<\/span>\n        <span class=\"na\">aws-region<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ inputs.aws-region }}<\/span>\n<\/code><\/pre><\/div>    <\/div>\n  <\/li>\n  <li>For Azure (<a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.github\/workflows\/deploy-to-azure-aci.yml#L56-L61\">link to step<\/a>):\n    <div class=\"language-yaml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>    <span class=\"pi\">-<\/span> <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s1\">'<\/span><span class=\"s\">Login<\/span><span class=\"nv\"> <\/span><span class=\"s\">to<\/span><span class=\"nv\"> <\/span><span class=\"s\">Azure<\/span><span class=\"nv\"> <\/span><span class=\"s\">using<\/span><span class=\"nv\"> <\/span><span class=\"s\">OIDC'<\/span>\n      <span class=\"na\">uses<\/span><span class=\"pi\">:<\/span> <span class=\"s\">azure\/login@v1<\/span>\n      <span class=\"na\">with<\/span><span class=\"pi\">:<\/span>\n        <span class=\"na\">client-id<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ secrets.az_client_id }}<\/span>\n        <span class=\"na\">tenant-id<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ secrets.az_tenant_id }}<\/span>\n        <span class=\"na\">subscription-id<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ secrets.az_subscription_id }}<\/span>\n<\/code><\/pre><\/div>    <\/div>\n  <\/li>\n  <li>For GCP (<a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.github\/workflows\/deploy-to-gcp-cloudrun.yml#L63-L69\">link to step<\/a>):\n    <div class=\"language-yaml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>    <span class=\"pi\">-<\/span> <span class=\"na\">id<\/span><span class=\"pi\">:<\/span> <span class=\"s1\">'<\/span><span class=\"s\">auth'<\/span>\n      <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s1\">'<\/span><span class=\"s\">Authenticate<\/span><span class=\"nv\"> <\/span><span class=\"s\">to<\/span><span class=\"nv\"> <\/span><span class=\"s\">Google<\/span><span class=\"nv\"> <\/span><span class=\"s\">Cloud<\/span><span class=\"nv\"> <\/span><span class=\"s\">using<\/span><span class=\"nv\"> <\/span><span class=\"s\">OIDC'<\/span>\n      <span class=\"na\">uses<\/span><span class=\"pi\">:<\/span> <span class=\"s1\">'<\/span><span class=\"s\">google-github-actions\/auth@v1'<\/span>\n      <span class=\"na\">with<\/span><span class=\"pi\">:<\/span>\n        <span class=\"na\">workload_identity_provider<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ secrets.workload_identity_provider }}<\/span>\n        <span class=\"na\">service_account<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ secrets.service_account }}<\/span>\n        <span class=\"na\">token_format<\/span><span class=\"pi\">:<\/span> <span class=\"s1\">'<\/span><span class=\"s\">access_token'<\/span>\n<\/code><\/pre><\/div>    <\/div>\n  <\/li>\n<\/ul>\n\n<p>You might have noticed that we are still using Actions secrets to pass the OIDC information to the cloud providers. This is just to add an extra layer of security: for instance, if that information was leaked and the OIDC trust relationship was too permissive, an attacker would perhaps be able to access the cloud resources from its own repository.<\/p>\n\n<p>Here this should not be the case - but we never know! - since during the setup I\u2019ve restricted the trust relationship to the following OIDC identities:<\/p>\n\n<ul>\n  <li>for AWS, only the identity <code class=\"language-plaintext highlighter-rouge\">repo:ghsioux\/multi-cloud-deployment-demo:environment:aws<\/code> (that is, the GitHub environment <code class=\"language-plaintext highlighter-rouge\">aws<\/code> of the repository <code class=\"language-plaintext highlighter-rouge\">ghsioux\/multi-cloud-deployment-demo<\/code>) is trusted;<\/li>\n  <li>similarly, for Azure, only the identity <code class=\"language-plaintext highlighter-rouge\">repo:ghsioux\/multi-cloud-deployment-demo:environment:azure<\/code> is trusted;<\/li>\n  <li>and for GCP, only the identity <code class=\"language-plaintext highlighter-rouge\">repo:ghsioux\/multi-cloud-deployment-demo:environment:gcp<\/code> is trusted.<\/li>\n<\/ul>\n\n<p>During the authentication process, the identity checks are performed by the cloud providers based on <a href=\"https:\/\/docs.github.com\/en\/actions\/deployment\/security-hardening-your-deployments\/about-security-hardening-with-openid-connect#understanding-the-oidc-token\">the token passed by the GitHub OIDC provider<\/a>.<\/p>\n\n<p>Allright! We have implemented some mecanisms to make the deployment <strong>geo-distributed<\/strong> and <strong>passwordless<\/strong>, now let\u2019s make it <strong>protected<\/strong> and <strong>versioned<\/strong>.<\/p>\n\n<h2 id=\"4---controlling-the-version-to-deploy\">4 - Controlling the version to deploy<\/h2>\n\n<p>The ones with eyes like the hawk will have observed that there is actually <a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.github\/workflows\/multi-cloud-deployment.yml#L11-L43\">an additional step<\/a> in the main worflow, that I\u2019ve not listed in the <a href=\"#1---general-view\">general view<\/a> above.<\/p>\n\n<p>To get a bit more context, let\u2019s have a look at the very beginning of <a href=\"https:\/\/github.com\/ghsioux\/multi-cloud-deployment-demo\/blob\/main\/.github\/workflows\/multi-cloud-deployment.yml#L2-L7\">the workflow<\/a>:<\/p>\n\n<div class=\"language-yaml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s2\">\"<\/span><span class=\"s\">\ud83d\ude80<\/span><span class=\"nv\"> <\/span><span class=\"s\">Multi-cloud<\/span><span class=\"nv\"> <\/span><span class=\"s\">PetClinic<\/span><span class=\"nv\"> <\/span><span class=\"s\">deployment<\/span><span class=\"nv\"> <\/span><span class=\"s\">demo\"<\/span>\n\n<span class=\"na\">on<\/span><span class=\"pi\">:<\/span>\n  <span class=\"na\">workflow_dispatch<\/span><span class=\"pi\">:<\/span>\n  <span class=\"na\">release<\/span><span class=\"pi\">:<\/span>\n    <span class=\"na\">types<\/span><span class=\"pi\">:<\/span> <span class=\"pi\">[<\/span><span class=\"nv\">published<\/span><span class=\"pi\">]<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<p>The workflow will be triggered manually or when a release is published. I\u2019m working alone on this project, but let\u2019s imagine a more complex scenario where multiple people collaborate. As a repository administrator, I would possibly want to restrict <strong>i)<\/strong> who can trigger\/re-run the workflow (e.g. only admin), and <strong>ii<\/strong>) which tags (and thus associated releases) are allowed to be deployed (e.g. only production tag).<\/p>\n\n<p>That\u2019s why I\u2019ve added a few checks in the first job of the workflow to ensure that:<\/p>\n\n<div class=\"language-yaml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>  <span class=\"na\">prereq_checks<\/span><span class=\"pi\">:<\/span>\n    <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">Ensure this workflow has been triggered by and admin on a protected release tag (v*)<\/span>\n    <span class=\"na\">runs-on<\/span><span class=\"pi\">:<\/span> <span class=\"s\">ubuntu-latest<\/span>\n    <span class=\"na\">env<\/span><span class=\"pi\">:<\/span>\n      <span class=\"na\">TRIGGERING_ACTOR<\/span><span class=\"pi\">:<\/span> <span class=\"s\">${{ github.triggering_actor }}<\/span>\n    <span class=\"na\">steps<\/span><span class=\"pi\">:<\/span>\n      <span class=\"pi\">-<\/span> <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">Fail if the workflow has been triggered manually with a non-release tag (i.e. not using the 'v*' regex)<\/span>\n        <span class=\"na\">run<\/span><span class=\"pi\">:<\/span> <span class=\"pi\">|<\/span>\n          <span class=\"s\">if [[ \"$GITHUB_REF\" != refs\/tags\/v* ]]; then<\/span>\n            <span class=\"s\">echo \"Only 'v*' tags and associated releases can be deployed, exiting.\"<\/span>\n            <span class=\"s\">exit 1<\/span>\n          <span class=\"s\">else<\/span>\n            <span class=\"s\">echo \"The workflow has been triggered on a release tag, continuing.\"<\/span>\n          <span class=\"s\">fi<\/span>\n      <span class=\"pi\">-<\/span> <span class=\"na\">name<\/span><span class=\"pi\">:<\/span> <span class=\"s\">Fail if the workflow has been triggered by a non-admin user<\/span>\n        <span class=\"na\">uses<\/span><span class=\"pi\">:<\/span> <span class=\"s\">actions\/github-script@v6<\/span>\n        <span class=\"na\">with<\/span><span class=\"pi\">:<\/span>\n          <span class=\"na\">script<\/span><span class=\"pi\">:<\/span> <span class=\"pi\">|<\/span>\n            <span class=\"s\">const TRIGGERING_ACTOR = process.env.TRIGGERING_ACTOR<\/span>\n            <span class=\"s\">github.rest.repos.getCollaboratorPermissionLevel({<\/span>\n              <span class=\"s\">owner: context.repo.owner,<\/span>\n              <span class=\"s\">repo: context.repo.repo,<\/span>\n              <span class=\"s\">username: TRIGGERING_ACTOR<\/span>\n              <span class=\"s\">}).then(response =&gt; {<\/span>\n                <span class=\"s\">if (response.data.permission == 'admin') {<\/span>\n                  <span class=\"s\">core.info('The github actor has admin permission on this repository. Continuing.')<\/span>\n                <span class=\"s\">} else {<\/span>\n                  <span class=\"s\">core.info('Only repository admins can trigger this workflow. Exiting.')<\/span>\n                  <span class=\"s\">process.exit(1)<\/span>\n                <span class=\"s\">}<\/span>\n              <span class=\"s\">})<\/span>\n<\/code><\/pre><\/div><\/div>\n\n<p>As you can see, only member with the <code class=\"language-plaintext highlighter-rouge\">admin<\/code> permission can trigger the workflow, and only tags matching the regexp <code class=\"language-plaintext highlighter-rouge\">v*<\/code> are allowed to be deployed. In parallel, I\u2019ve set up a <a href=\"https:\/\/docs.github.com\/en\/enterprise-cloud@latest\/repositories\/managing-your-repositorys-settings-and-features\/managing-repository-settings\/configuring-tag-protection-rules\">tag protection rules<\/a> to restrict <code class=\"language-plaintext highlighter-rouge\">v*<\/code> tags creation to privileged members only. This tag protection rule will also apply when creating a release (i.e. a non-privileged member won\u2019t be authorized to create a release with a tag matching <code class=\"language-plaintext highlighter-rouge\">v*<\/code>).<\/p>\n\n<p>If you combine this with the use of the 3 dedicated GitHub environments, which are themselves <a href=\"https:\/\/docs.github.com\/en\/actions\/deployment\/targeting-different-environments\/using-environments-for-deployment#deployment-branches\">bound to the branches<\/a> matching <code class=\"language-plaintext highlighter-rouge\">v*<\/code>  (i.e. our protected tags) and protected to require <a href=\"https:\/\/docs.github.com\/en\/actions\/deployment\/targeting-different-environments\/using-environments-for-deployment#required-reviewers\">a manual approval<\/a> before deployment, the overall level of security is fairly satisfying.<\/p>\n\n<h2 id=\"5---the-pieces-together-aka-time-to-trigger\">5 - The pieces together a.k.a. time to trigger<\/h2>\n\n<p>Congrats, you made it so far, and now comes the time to enjoy and trigger \ud83d\udd2b<\/p>\n\n<p>Let\u2019s say that the developers have been working hard on the application to add new features, and they are ready to deploy the new version to production.<\/p>\n\n<p>A member with the <code class=\"language-plaintext highlighter-rouge\">admin<\/code> permission on the repository will create a new release with a tag matching the <code class=\"language-plaintext highlighter-rouge\">v*<\/code> regexp:\n<img src=\"\/assets\/images\/2023-04-05-multicloud-deployment\/release.png\" alt=\"release_creation\" title=\"Release creation\" \/><\/p>\n\n<p>This will trigger the main workflow, and after the checks have passed, the image is built and pushed to the GitHub container registry. Then the three reusable workflows are called, and since they are working on protected environments, a manual approval is required (e.g. by the SRE team):\n<img src=\"\/assets\/images\/2023-04-05-multicloud-deployment\/deployment_approval.png\" alt=\"deployments_approval\" title=\"Deployments approval\" \/><\/p>\n\n<p>Once the approval is granted, the workflows will continue and the new version of the application will be deployed to our three cloud providers:\n<img src=\"\/assets\/images\/2023-04-05-multicloud-deployment\/deployment_succeeded.png\" alt=\"deployment_succeeded\" title=\"Deployment succeeded\" \/><\/p>\n\n<p>Is that all? Could be, but you know, sometimes accidents happen. Let\u2019s imagine that\u2019s the case, and that the new version of the application is not working as expected. Mayday, mayday, we need to rollback! Nothing more simple, the administrator will just trigger the workflow again, but this time manually, and on the tag matching the previous release:\n<img src=\"\/assets\/images\/2023-04-05-multicloud-deployment\/rollback.png\" alt=\"rollback\" title=\"Rollback triggering\" \/><\/p>\n\n<p>Phew, we\u2019re going back to business! \ud83c\udf89<\/p>\n\n<h2 id=\"6---next-steps\">6 - Next steps<\/h2>\n\n<p>That was a lot of fun, and I hope you enjoyed it as much as I did. As usual, this is not for production use, and there is room for improvement. I\u2019m sure you have some ideas on how to make this even better!<\/p>\n\n<p>We could for instance:<\/p>\n<ul>\n  <li>define stricter role permissions and RBAC for our service accounts;<\/li>\n  <li>implement some load-balancing mechanisms (e.g. DNS round-robin, <a href=\"https:\/\/doc.traefik.io\/traefik\/\">Traefik<\/a>) to make the application available on a single URL;<\/li>\n  <li>extend the workflow to implement blue\/green deployments, A\/B testing or canary release approach.<\/li>\n<\/ul>\n\n<p>But the sun is shining, and the flowers are blooming, so let\u2019s leave it here for now.<\/p>\n\n<p>Gassh\u014d \ud83d\ude4f<\/p>\n"},{"title":"Securing code and its deployment with GitHub branch protection rules","link":{"@attributes":{"href":"https:\/\/ghsioux.github.io\/2023\/02\/03\/securing-branches-and-deployments"}},"updated":"2023-02-03T00:00:00+01:00","id":"https:\/\/ghsioux.github.io\/2023\/02\/03\/securing-branches-and-deployments","content":"<blockquote>\n  <p>\u26a0\ufe0f <strong>Update:<\/strong> Protection rules have now been replaced with more powerful <a href=\"\/2025\/01\/07\/7-cool-things-with-rulesets\">rulesets<\/a> that offer enhanced control and flexibility over the repository\u2019s workflows and branch protections.<\/p>\n<\/blockquote>\n\n<p>Hey shinobis, welcome back to the dojo! Do you remember the previous blog post about <a href=\"https:\/\/ghsioux.github.io\/2023\/01\/10\/ghes-azure-gitops\">deploying GitHub Enterprise Server on Azure the GitOps way<\/a>? In this post, let\u2019s go a bit further and see some specific steps that secured the pull-request (PR) process and the resulting infrastructure deployment.<\/p>\n\n<h2 id=\"1---the-pr-process-and-its-shurikens\">1 - The PR Process and its shurikens<\/h2>\n\n<p>In the <a href=\"https:\/\/github.com\/ghsioux-octodemo\/deploy-ghes-azure-terraform\">repository<\/a>, <a href=\"https:\/\/github.com\/ghsioux-octodemo\/deploy-ghes-azure-terraform\/pull\/2\">a PR  <code class=\"language-plaintext highlighter-rouge\">feature_branch -&gt; main<\/code><\/a> is opened to implement a new feature for the Terraform-coded GHES infrastructure. We\u2019ve seen previously that <a href=\"https:\/\/github.com\/ghsioux-octodemo\/deploy-ghes-azure-terraform\/tree\/main\/.github\/workflows\">some GitHub Actions workflows<\/a> run on that PR to unit test\/analyze the code and generate the according Terraform plan. If the PR is merged, the Terraform plan is applied to the target cloud environment - here Azure - and the GHES infrastructure is deployed with the new feature.<\/p>\n\n<p>I work alone on this repository, and that\u2019s for experimentations only, so overall this process is fine. In many cases however, multiple developers and teams collaborate on the same codebase, and that codebase might be deployed to production environments. In such situations, there are some flying shurikens we need to handle well \u2726\u2726\u2726.<\/p>\n\n<p>What if:<\/p>\n\n<ul>\n  <li>the new code is pushed directly to the <code class=\"language-plaintext highlighter-rouge\">main<\/code> branch without being reviewed &amp; approved?<\/li>\n  <li>the new code is not tested for potential bugs or analyzed for potential vulnerabilities (e.g. an Azure resource with too permissive permissions)?<\/li>\n  <li>the new code is deployed on a production environment without any notification \/ approval \/ preparation (e.g. from the SRE team)?<\/li>\n<\/ul>\n\n<p>Some cyberninjas say that the risk 0 is just an illusion. But still, let\u2019s see how we can mitigate these risks using a mix of branch and environment protection rules.<\/p>\n\n<h2 id=\"2---protecting-the-branch\">2 - Protecting the branch<\/h2>\n\n<p><a href=\"https:\/\/docs.github.com\/en\/repositories\/configuring-branches-and-merges-in-your-repository\/defining-the-mergeability-of-pull-requests\/about-protected-branches\">Branch protection rules<\/a> are a great way to maintain the good health of a branch while collaborating. They can be used for instance to ensure that <a href=\"https:\/\/docs.github.com\/en\/repositories\/configuring-branches-and-merges-in-your-repository\/defining-the-mergeability-of-pull-requests\/about-protected-branches#require-pull-request-reviews-before-merging\">any new code has been reviewed<\/a> before being merged, or that specific <a href=\"https:\/\/docs.github.com\/en\/repositories\/configuring-branches-and-merges-in-your-repository\/defining-the-mergeability-of-pull-requests\/about-protected-branches#require-status-checks-before-merging\">CI jobs have passed<\/a> during the PR process.<\/p>\n\n<p>In my repo, the <code class=\"language-plaintext highlighter-rouge\">main<\/code> branch is the one from where the Terraform code is applied in Azure. I\u2019ve therefore set up the following rules for that branch:<\/p>\n<ul>\n  <li>a PR is required in order to update the code (i.e. no direct push allowed);<\/li>\n  <li>the code of the PR must be approved by at least one <a href=\"https:\/\/docs.github.com\/en\/repositories\/managing-your-repositorys-settings-and-features\/customizing-your-repository\/about-code-owners\">code owner<\/a>;<\/li>\n  <li>some jobs of the PR-triggered Actions workflows must pass successfully (they are what we call <a href=\"https:\/\/docs.github.com\/en\/repositories\/configuring-branches-and-merges-in-your-repository\/defining-the-mergeability-of-pull-requests\/about-protected-branches#require-status-checks-before-merging\">required status checks<\/a>);<\/li>\n  <li>the commits in the PR must be <a href=\"https:\/\/docs.github.com\/en\/authentication\/managing-commit-signature-verification\/about-commit-signature-verification\">signed and verified<\/a>.<\/li>\n<\/ul>\n\n<p><img src=\"\/assets\/images\/2023-02-03-securing-branches-and-deployments\/protection_rules.png\" alt=\"branch protection rules\" title=\"Branch protection rules\" \/><\/p>\n\n<p>Each of these rules must be respected before the PR can be merged. All together, they form a nice barrier against the two first shurikens we saw above.<\/p>\n\n<p>The first and second rules ensure that the code is reviewed by the relevant team\/people depending on what\u2019s being changed. Here, it could be for example the IaC team having a look at the new Terraform code and the according plan. Such rules normally ensure that the branch is always in a verified and working state.<\/p>\n\n<p>The third rule ensures that the <a href=\"https:\/\/github.com\/ghsioux-octodemo\/deploy-ghes-azure-terraform\/blob\/main\/.github\/workflows\/tf-unit-tests.yml#L9-L33\">\u201cUnit test\u201d<\/a>, <a href=\"https:\/\/github.com\/ghsioux-octodemo\/deploy-ghes-azure-terraform\/blob\/main\/.github\/workflows\/tf-plan-apply.yml#LL30-L122C15\">\u201cTerraform plan\u201d<\/a> and <a href=\"https:\/\/github.com\/ghsioux-octodemo\/deploy-ghes-azure-terraform\/blob\/main\/.github\/workflows\/tf-unit-tests.yml#LL35-L48C26\">\u201cCode Scanning\u201d<\/a> jobs have run successfully. This allows to <strong>i)<\/strong> automatically test and analyze the new code before merging, and <strong>ii)<\/strong>  generate the Terraform plan and <a href=\"https:\/\/github.com\/ghsioux-octodemo\/deploy-ghes-azure-terraform\/blob\/main\/.github\/workflows\/tf-plan-apply.yml#LL107-L122C15\">make it available<\/a> as <a href=\"https:\/\/github.com\/ghsioux-octodemo\/deploy-ghes-azure-terraform\/pull\/2#issuecomment-1376268820\">a PR comment<\/a> for review purposes. I\u2019ll likely talk more about the code scanning part in a future blog post.<\/p>\n\n<p>We can see these required status checks in different locations, including the PR \u201cConversation\u201d and \u201cChecks\u201d tab:<\/p>\n\n<p><img src=\"\/assets\/images\/2023-02-03-securing-branches-and-deployments\/checks.png\" alt=\"required status checks\" title=\"Required status checks\" \/><\/p>\n\n<p>Finally, the last rule adds some extra-security by requiring valid cryptographic signatures on every commits. Such mechanism makes it more difficult to impersonate someone else and push code on its behalf. \nBy the way, have you heard about <a href=\"https:\/\/docs.github.com\/en\/authentication\/managing-commit-signature-verification\/displaying-verification-statuses-for-all-of-your-commits\">GitHub vigilant mode<\/a>?<\/p>\n\n<h2 id=\"3---deployments-rhymes-with-environments\">3 - Deployments rhymes with environments<\/h2>\n\n<p>Allright, the PR has successfully passed all the <code class=\"language-plaintext highlighter-rouge\">main<\/code> branch protection rules so it is merged. Now the new Terraform code is ready to be deployed, and we have to be sure it will go smoothly. Let\u2019s leverage <a href=\"https:\/\/docs.github.com\/en\/actions\/deployment\/targeting-different-environments\/using-environments-for-deployment\">GitHub Environments<\/a> to this end.<\/p>\n\n<p>Environments are logical deployment targets for a repository. They are used in Actions workflows to customize code deployments through the use of scoped <a href=\"https:\/\/docs.github.com\/en\/actions\/deployment\/targeting-different-environments\/using-environments-for-deployment#environment-secrets\">variables and secrets<\/a>. An environment can be protected by some rules, and be associated with a specific branch so only the code of this branch will be allowed to be deployed.<\/p>\n\n<p>Here is the <code class=\"language-plaintext highlighter-rouge\">production<\/code> environment I\u2019ve created for my repo:<\/p>\n\n<p><img src=\"\/assets\/images\/2023-02-03-securing-branches-and-deployments\/environment.png\" alt=\"environment_secrets_variables\" title=\"Environment secrets and variables\" \/><\/p>\n\n<p>This environment is scoped to the <code class=\"language-plaintext highlighter-rouge\">main<\/code> branch and will target a given Azure tenant through its <code class=\"language-plaintext highlighter-rouge\">AZURE_CLIENT_ID<\/code> secret - used by the \u201cTerraform Apply\u201d job to <a href=\"https:\/\/docs.github.com\/en\/actions\/deployment\/security-hardening-your-deployments\/configuring-openid-connect-in-azure\">OIDC-authenticate in Azure<\/a>. In a more realistic context, we could imagine a second environment named <code class=\"language-plaintext highlighter-rouge\">staging<\/code> with its own <code class=\"language-plaintext highlighter-rouge\">AZURE_CLIENT_ID<\/code> secret to target another Azure tenant. I\u2019ve also added a protection rule specifying that the user @ghsioux (\ud83e\udd77) must manually approve the deployment beforehand.<\/p>\n\n<p>Like this, when the PR is merged and the <code class=\"language-plaintext highlighter-rouge\">main<\/code> branch updated, the \u201cTerraform Apply\u201d job is triggered and I have to approve the deployment first:<\/p>\n\n<p><img src=\"\/assets\/images\/2023-02-03-securing-branches-and-deployments\/review_deployment_1.png\" alt=\"deployment review required\" title=\"deployment review required\" \/><\/p>\n\n<p><img src=\"\/assets\/images\/2023-02-03-securing-branches-and-deployments\/review_deployment_2.png\" alt=\"deployment review done\" title=\"deployment review done\" \/><\/p>\n\n<p>Once approved, waiting a few minutes for the job to complete, we can see the deployment is active and the GHES URL available:<\/p>\n\n<p><img src=\"\/assets\/images\/2023-02-03-securing-branches-and-deployments\/deployment.png\" alt=\"successful_deployment\" title=\"Successful deployment\" \/><\/p>\n\n<p>You get it, with environments and their associated protection rules, the last shuriken isn\u2019t a threat anymore.<\/p>\n\n<h2 id=\"4---shurikens-to-come\">4 - Shurikens to come<\/h2>\n\n<p>Today we have seen how to protect our code from some shurikens, but there are still more to come. For instance, what if sensitive data (e.g. an Azure access key) was pushed to the repo? Or new compliance rules should be enforced on all the repositories of a big organization? We could investigate the use of <a href=\"https:\/\/docs.github.com\/en\/code-security\/secret-scanning\/about-secret-scanning\">secret scanning<\/a> and <a href=\"https:\/\/docs.github.com\/en\/actions\/using-workflows\/required-workflows\">required workflows<\/a> for this.<\/p>\n\n<p>Another improvement could be to switch from the <a href=\"https:\/\/github.blog\/2023-02-02-enabling-branch-deployments-through-issueops-with-github-actions\/#understanding-the-branch-deploy-model\"><strong>deploy -&gt; merge<\/strong> model to the <strong>branch deploy<\/strong> model<\/a> for an even safer <code class=\"language-plaintext highlighter-rouge\">main<\/code> branch.<\/p>\n\n<p>But that\u2019s another story for another time.<\/p>\n\n<p>Gassh\u014d! \ud83d\ude4f<\/p>\n"},{"title":"Deploying GitHub Enterprise Server on Azure the GitOps way","link":{"@attributes":{"href":"https:\/\/ghsioux.github.io\/2023\/01\/10\/ghes-azure-gitops"}},"updated":"2023-01-10T00:00:00+01:00","id":"https:\/\/ghsioux.github.io\/2023\/01\/10\/ghes-azure-gitops","content":"<h2 id=\"0---introduction\">0 - Introduction<\/h2>\n\n<p>As a zen apprentice I like to free my mind as much as I can, specially regarding if\/where\/how my ressources are deployed in the cloud \u2601\ufe0f.<\/p>\n\n<p>In this post I\u2019ll share a simple way to do so, through the example of a GitHub Enterprise Server (GHES) instance that I use for testing purposes. This GHES instance is described as Terraform code and deployed in Azure using GitHub Actions workflows.<\/p>\n\n<p>The code can be found <a href=\"https:\/\/github.com\/ghsioux-octodemo\/deploy-ghes-azure-terraform\/\">in this repository<\/a> which is based on <a href=\"https:\/\/github.com\/Azure-Samples\/terraform-github-actions\/\">Azure-Samples\/terraform-github-actions<\/a>, a sample repository that shows how to use GitHub Actions workflows to manage Azure infrastructure with Terraform.<\/p>\n\n<h2 id=\"1---the-infrastructure\">1 - The infrastructure<\/h2>\n<p>The Terraform code used to describe the target infrastructure - that is, the GHES related resources - is split into several files:<\/p>\n\n<div class=\"language-zsh highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>\u276f tree <span class=\"nt\">-Pa<\/span> <span class=\"s1\">'*.tf|*.tfvars|*.hcl'<\/span> <span class=\"nt\">--prune<\/span>\n<span class=\"nb\">.<\/span>\n\u251c\u2500\u2500 .terraform.lock.hcl\n\u251c\u2500\u2500 main.tf\n\u251c\u2500\u2500 outputs.tf\n\u251c\u2500\u2500 providers.tf\n\u251c\u2500\u2500 terraform.tfvars\n\u2514\u2500\u2500 variables.tf\n<\/code><\/pre><\/div><\/div>\n<p>Overall this is a typical file structure for a simple Terraform project:<\/p>\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">main.tf<\/code> contains the main Terraform code, where Azure ressources (e.g. storage account, vnet, VM, etc.) are defined to be deployed;<\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">providers.tf<\/code> references plugins that allow Terraform to interact with cloud providers (here Azure);<\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">variables.tf<\/code> and <code class=\"language-plaintext highlighter-rouge\">terraform.tfvars<\/code> respectively <strong>defines<\/strong> and <strong>assign custom values<\/strong> to variables used in <code class=\"language-plaintext highlighter-rouge\">main.tf<\/code> to customize the resources;<\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">outputs.tf<\/code> defines the outputs that the Terraform code will return regarding the deployed resources (e.g. Azure resource group, VM\u2019s public IP, FQDN).<\/li>\n<\/ul>\n\n<p>The special file <code class=\"language-plaintext highlighter-rouge\">.terraform.lock.hcl<\/code> is a lock file ensuring that the same versions of the plugins are used by all collaborators of the repo.<\/p>\n\n<h2 id=\"2---the-action-workflows\">2 - The Action workflows<\/h2>\n\n<p>The <code class=\"language-plaintext highlighter-rouge\">.github\/workflows<\/code> directory contains the GitHub Actions workflows that will work with the Terraform code.<\/p>\n\n<div class=\"language-zsh highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>\u276f tree <span class=\"nt\">-Pa<\/span> <span class=\"s1\">'*.yml'<\/span> <span class=\"nt\">--prune<\/span>\n<span class=\"nb\">.<\/span>\n\u2514\u2500\u2500 .github\n    \u2514\u2500\u2500 workflows\n        \u251c\u2500\u2500 tf-drift.yml\n        \u251c\u2500\u2500 tf-plan-apply.yml\n        \u2514\u2500\u2500 tf-unit-tests.yml\n<\/code><\/pre><\/div><\/div>\n\n<p>Here are the main characteristics of these workflows:<\/p>\n\n<table>\n  <thead>\n    <tr>\n      <th>Workflow<\/th>\n      <th>Triggering events<\/th>\n      <th>Description<\/th>\n    <\/tr>\n  <\/thead>\n  <tbody>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">tf-unit-tests.yml<\/code><\/td>\n      <td><code class=\"language-plaintext highlighter-rouge\">push<\/code> on any branch<\/td>\n      <td>Runs unit tests and analyze the Terraform code.<\/td>\n    <\/tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">tf-plan-apply.yml<\/code><\/td>\n      <td><code class=\"language-plaintext highlighter-rouge\">pull_request<\/code> or <code class=\"language-plaintext highlighter-rouge\">push<\/code> to <code class=\"language-plaintext highlighter-rouge\">main<\/code> branch<\/td>\n      <td>Builds the Terraform plan and applies it in Azure.<\/td>\n    <\/tr>\n    <tr>\n      <td><code class=\"language-plaintext highlighter-rouge\">tf-drift.yml<\/code><\/td>\n      <td><code class=\"language-plaintext highlighter-rouge\">schedule<\/code> or manual<\/td>\n      <td>Detects drifts between the desired and the current infrastructure.<\/td>\n    <\/tr>\n  <\/tbody>\n<\/table>\n\n<p>A nice thing is that the Terraform state is stored in an Azure storage account, so that it can be shared between the workflows to retrieve the currently deployed infrastructure. For more information, see <a href=\"https:\/\/github.com\/ghsioux-octodemo\/deploy-ghes-azure-terraform\/blob\/main\/README.md\">the README<\/a> of the repository.<\/p>\n\n<p>Another noteworthy point is the use of the <a href=\"https:\/\/docs.github.com\/en\/actions\/using-workflows\/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore\"><code class=\"language-plaintext highlighter-rouge\">paths<\/code><\/a> keyword in the workflow files, allowing to trigger the workflows only if the Terraform files have been modified, e.g.:<\/p>\n\n<div class=\"language-yaml highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"na\">on<\/span><span class=\"pi\">:<\/span>\n  <span class=\"na\">push<\/span><span class=\"pi\">:<\/span>\n    <span class=\"na\">paths<\/span><span class=\"pi\">:<\/span>\n    <span class=\"pi\">-<\/span> <span class=\"s1\">'<\/span><span class=\"s\">**.tf'<\/span>\n    <span class=\"pi\">-<\/span> <span class=\"s1\">'<\/span><span class=\"s\">**.tfvars'<\/span> \n<\/code><\/pre><\/div><\/div>\n\n<h2 id=\"3---putting-it-all-together-aka-the-gitops-part\">3 - Putting it all together (a.k.a. the GitOps part)<\/h2>\n\n<p>Combining both Terraform and GitHub Actions allows us to embrace the GitOps paradigm. Here is a typical process leveraging this approach:<\/p>\n<ol>\n  <li>\n    <p>Clone the repo and create a new branch to work on a new feature, or to update a Terraform variable that\u2019ll in turn update the GHES deployment;<\/p>\n  <\/li>\n  <li>\n    <p>Once the Terraform code has been updated, push the changes to the remote repo and open <a href=\"https:\/\/github.com\/ghsioux-octodemo\/deploy-ghes-azure-terraform\/pull\/2\">a pull request<\/a> towards the <code class=\"language-plaintext highlighter-rouge\">main<\/code> branch;<\/p>\n  <\/li>\n  <li>\n    <p>The <code class=\"language-plaintext highlighter-rouge\">tf-unit-tests.yml<\/code> workflow is triggered to test the Terraform code;\n<img src=\"\/assets\/images\/2023-01-10-ghes-azure-gitops\/unit-tests.png\" alt=\"the unit tests workflow\" title=\"The unit tests workflow\" \/><\/p>\n  <\/li>\n  <li>In parallel, the <code class=\"language-plaintext highlighter-rouge\">tf-plan-apply.yml<\/code> workflow is triggered to build the Terraform plan and to share it as a comment in the PR conversation, for review purposes;\n<img src=\"\/assets\/images\/2023-01-10-ghes-azure-gitops\/terraform_plan.png\" alt=\"the Terraform plan\" title=\"The Terraform plan\" \/><\/li>\n  <li>\n    <p>After all the PR <a href=\"https:\/\/docs.github.com\/en\/repositories\/configuring-branches-and-merges-in-your-repository\/defining-the-mergeability-of-pull-requests\/about-protected-branches#require-status-checks-before-merging\">required checks<\/a> and <a href=\"https:\/\/docs.github.com\/en\/pull-requests\/collaborating-with-pull-requests\/reviewing-changes-in-pull-requests\/approving-a-pull-request-with-required-reviews\">reviews<\/a> have passed, the PR can be merged into the <code class=\"language-plaintext highlighter-rouge\">main<\/code> branch;<\/p>\n  <\/li>\n  <li>Once the PR merged, the <code class=\"language-plaintext highlighter-rouge\">tf-plan-apply.yml<\/code> workflow is triggered again, and this time it applies the Terraform plan in Azure, effectively deploying the GHES resources;\n<img src=\"\/assets\/images\/2023-01-10-ghes-azure-gitops\/tf-plan-apply-push.png\" alt=\"the Terraform apply\" title=\"The Terraform apply\" \/><\/li>\n<\/ol>\n\n<p>At this point, my GitHub Enterprise Server instance is deployed in Azure and ready to be used (or well, to be set up if it\u2019s the first boot :)\n<img src=\"\/assets\/images\/2023-01-10-ghes-azure-gitops\/ghes_first_boot.png\" alt=\"GHES first boot\" title=\"GHES first boot\" \/><\/p>\n\n<p>Now that the deployment is done, we want to ensure the infrastructure is always in line with the Terraform code.\nIndeed, unwanted changes might occur in the infrastructure along time, like the VM being deleted manually or the DNS name being updated. This is where the <code class=\"language-plaintext highlighter-rouge\">tf-drift.yml<\/code> workflow comes into play.<\/p>\n\n<p>This workflow is triggered every day to detect drifts between the desired (i.e. the Terraform code) and the currently deployed infrastructure. If drifts are detected, the workflow will open a new issue, and I\u2019ll receive a <a href=\"https:\/\/docs.github.com\/en\/account-and-profile\/managing-subscriptions-and-notifications-on-github\/setting-up-notifications\/configuring-notifications#about-custom-notifications\">notification from GitHub<\/a>:\n<img src=\"\/assets\/images\/2023-01-10-ghes-azure-gitops\/drift.png\" alt=\"the drift issue\" title=\"The drift issue\" \/><\/p>\n\n<h2 id=\"4---the-end\">4 - The end<\/h2>\n<p>That\u2019s it for today folks, I hope you enjoyed this post and that it will help you to get started with Terraform and GitHub Actions.<\/p>\n\n<p>As usual, this is more like a PoC and many improvements can be done. Zen masters often say that \u201cthe journey is never ending\u201d.<\/p>\n\n<p>As a future work, I\u2019d like to play with <a href=\"https:\/\/registry.terraform.io\/providers\/integrations\/github\/latest\/docs\">the Terraform provider for GitHub<\/a> to store GHES configuration (e.g. organizations, policies, teams) as code, and write additional workflows to leverage it. I\u2019ll also write another post to go further into the <code class=\"language-plaintext highlighter-rouge\">main<\/code> branch protection rules and the unit tests workflow, as it includes some nice <a href=\"https:\/\/docs.github.com\/en\/code-security\/code-scanning\/automatically-scanning-your-code-for-vulnerabilities-and-errors\/about-code-scanning\">code scanning<\/a> features.<\/p>\n\n<p>Oh and by the way, this blog post has been co-written with Copilot \ud83e\udd16.<\/p>\n\n<p>Gassh\u014d! \ud83d\ude4f<\/p>\n"}]}