Skip to content

Commit

Permalink
Merge pull request #37 from deploymenttheory/feat-test
Browse files Browse the repository at this point in the history
script adjustments
  • Loading branch information
thejoeker12 authored Oct 31, 2024
2 parents dee94cd + eda4024 commit d59ec73
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
28 changes: 14 additions & 14 deletions .github/scripts/update_pr.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
"""script to update a PR or make one, update this soon."""

import os
import sys
from datetime import datetime
import json
from github import Github
from github.GithubException import GithubException

TOKEN = os.environ.get("GITHUB_TOKEN")
DROPFILE_PATH = os.environ.get("ARTIFACT_PATH")
TYPE = os.environ.get("RUN_TYPE")

if not TOKEN or not DROPFILE_PATH:
raise ValueError(f"One or more missing env vars: TOKEN: {TOKEN}, DROPFILE_FN: {DROPFILE_PATH}")

GH = Github(TOKEN)
ENV_VARS = [TOKEN, DROPFILE_PATH, TYPE]

if any(i == "" for i in ENV_VARS):
raise KeyError(f"one or more env vars are empty: {ENV_VARS}")

GH = 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)

Expand Down Expand Up @@ -65,26 +65,26 @@ def update_pr_with_text(pr):
pr: github.PullRequest.PullRequest object
message (str): Comment text to add
"""
comment = "You shouldn't see this"

comments = []
with open(DROPFILE_PATH + "/outputs.json", "r", encoding="UTF-8") as f:
json_data = json.load(f)


plan_output = json.dumps(json_data["plan_output"], indent=2)
formatted_comment = json.dumps(json_data, indent=2)
if TYPE == "plan":
comments.append(json.dumps(json_data["plan_output"], indent=2))

comments.append(json.dumps(json_data, indent=2))

try:
pr.create_issue_comment(formatted_comment)
pr.create_issue_comment(plan_output)
print(f"Added comment to PR #{pr.number}")
for c in comments:
pr.create_issue_comment(c)

except GithubException as e:
print(f"Error adding comment: {e}")
raise


def main():
"""main"""
pr = get_pr()
update_pr_with_text(pr)

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/demo_1_plan_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,4 @@ jobs:
uses: ./.github/workflows/update_pr.yml
with:
outputs-payload: ${{ vars.PLAN_OUTPUT_ARTIFACT_NAME }}
run-type: plan
1 change: 1 addition & 0 deletions .github/workflows/demo_2_apply_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ jobs:
uses: ./.github/workflows/update_pr.yml
with:
outputs-payload: ${{ vars.APPLY_OUTPUT_ARTIFACT_NAME }}
run-type: "apply"



Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/update_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
outputs-payload:
required: true
type: string

run-type:
required: true
type: string

jobs:

Expand Down Expand Up @@ -43,6 +47,7 @@ jobs:
run: python .github/scripts/update_pr.py
env:
ARTIFACT_PATH: ${{ steps.download-artifact.outputs.download-path }}
RUN_TYPE: ${{ inputs.run-type }}



Expand Down
11 changes: 8 additions & 3 deletions workload/terraform/jamfpro/categories.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ resource "jamfpro_category" "category_3" {
name = "Marketing-1 - JL Demo V2"
}

# resource "jamfpro_category" "category_4" {
# name = "Marketing - JL Demo V2 - 2"
# }
resource "jamfpro_category" "category_4" {
name = "Marketing - JL Demo V2 - 2"
}


resource "jamfpro_category" "category_5" {
name = "Marketing - JL Demo V2 - 22"
}

0 comments on commit d59ec73

Please sign in to comment.