generated from deploymenttheory/Template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from deploymenttheory/dev-testing
Dev testing
- Loading branch information
Showing
5 changed files
with
147 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""script to update the text on a release""" | ||
|
||
import os | ||
import json | ||
import github | ||
from github.GithubException import GithubException | ||
|
||
REPO_PATH = "deploymenttheory/terraform-demo-jamfpro-v2" | ||
|
||
TOKEN = os.environ.get("GITHUB_TOKEN") | ||
DROPFILE_PATH = os.environ.get("ARTIFACT_PATH") | ||
GIT_TAG = os.environ.get("RELEASE_TAG") | ||
|
||
ENV_VARS = [TOKEN, DROPFILE_PATH] | ||
|
||
if any (i == "" for i in ENV_VARS): | ||
raise KeyError(f"one or more env vars are empty: {ENV_VARS}") | ||
|
||
|
||
GH = github.Github(TOKEN) | ||
|
||
def open_drop_file() -> dict: | ||
"""opens the drop file""" | ||
with open(DROPFILE_PATH + "/outputs.json", "r", encoding="UTF-8") as f: | ||
return json.load(f) | ||
|
||
|
||
def get_update_release(): | ||
"""gets a tag""" | ||
try: | ||
repo = GH.get_repo(REPO_PATH) | ||
release = repo.get_release(GIT_TAG) | ||
|
||
except GithubException as e: | ||
print(f"GitHub API error: {e}") | ||
raise | ||
except Exception as e: | ||
print(f"Unexpected error: {e}") | ||
raise | ||
|
||
file = open_drop_file() | ||
message = f"{release.body}\nApply Result:\n{json.dumps(file, indent=2)}" | ||
release.update_release( | ||
message=message | ||
) | ||
|
||
|
||
def main(): | ||
get_update_release() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Add PR Comment | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
outputs-payload: | ||
required: true | ||
type: string | ||
|
||
git-tag: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
|
||
update-release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: read | ||
pull-requests: write | ||
contents: write | ||
|
||
container: | ||
image: ghcr.io/${{ github.repository }}/python:latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download artifact | ||
id: download-artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ inputs.outputs-payload }} | ||
|
||
- name: Run pr update python utility | ||
run: python .github/scripts/update_pr.py | ||
env: | ||
ARTIFACT_PATH: ${{ steps.download-artifact.outputs.download-path }} | ||
GIT_TAG: ${{ inputs.git-tag }} | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters