From d455c5b01a8e766e597e8e0710e276467a4f0a32 Mon Sep 17 00:00:00 2001 From: gomez385 Date: Tue, 1 Oct 2024 17:35:08 -0400 Subject: [PATCH 1/9] make fix --- .github/workflows/terraform_plan.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/terraform_plan.yaml b/.github/workflows/terraform_plan.yaml index 1f50699..d96ab54 100644 --- a/.github/workflows/terraform_plan.yaml +++ b/.github/workflows/terraform_plan.yaml @@ -52,7 +52,7 @@ jobs: - name: Setup GITHUB Credentials id: github_credentials run: - python encode_jwt.py "${{ secrets.GITHUB_APP_PEM_FILE }}" "${{ vars.GITHUB_APP_INSTALLATION_ID }}" https://github.e.it.census.gov/" #>> $GITHUB_ENV + python encode_jwt.py "${{ secrets.GITHUB_APP_PEM_FILE }}" "${{ vars.GITHUB_APP_INSTALLATION_ID }}" "https://github.e.it.census.gov/" #>> $GITHUB_ENV - name: Terraform Init id: init From cae233120d2d09b6cd67f2d8e3066a1c99d3fef3 Mon Sep 17 00:00:00 2001 From: gomez385 Date: Tue, 1 Oct 2024 17:38:14 -0400 Subject: [PATCH 2/9] make fix --- .github/workflows/terraform_plan.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/terraform_plan.yaml b/.github/workflows/terraform_plan.yaml index d96ab54..c4847f3 100644 --- a/.github/workflows/terraform_plan.yaml +++ b/.github/workflows/terraform_plan.yaml @@ -52,7 +52,7 @@ jobs: - name: Setup GITHUB Credentials id: github_credentials run: - python encode_jwt.py "${{ secrets.GITHUB_APP_PEM_FILE }}" "${{ vars.GITHUB_APP_INSTALLATION_ID }}" "https://github.e.it.census.gov/" #>> $GITHUB_ENV + python encode_jwt.py "$GITHUB_APP_PEM_FILE $GITHUB_APP_INSTALLATION_ID $GITHUB_BASE_URL" #>> $GITHUB_ENV - name: Terraform Init id: init From b89c1654b40319eaac577a83238663c7a2cc77ed Mon Sep 17 00:00:00 2001 From: gomez385 Date: Tue, 1 Oct 2024 17:39:34 -0400 Subject: [PATCH 3/9] make fix --- .github/workflows/terraform_plan.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/terraform_plan.yaml b/.github/workflows/terraform_plan.yaml index c4847f3..d4b5f66 100644 --- a/.github/workflows/terraform_plan.yaml +++ b/.github/workflows/terraform_plan.yaml @@ -52,7 +52,7 @@ jobs: - name: Setup GITHUB Credentials id: github_credentials run: - python encode_jwt.py "$GITHUB_APP_PEM_FILE $GITHUB_APP_INSTALLATION_ID $GITHUB_BASE_URL" #>> $GITHUB_ENV + python encode_jwt.py "$GITHUB_APP_PEM_FILE" "$GITHUB_APP_INSTALLATION_ID" "$GITHUB_BASE_URL" #>> $GITHUB_ENV - name: Terraform Init id: init From b37a747abfdc5745fb33416acc8002433aeebd50 Mon Sep 17 00:00:00 2001 From: gomez385 Date: Tue, 1 Oct 2024 17:42:45 -0400 Subject: [PATCH 4/9] make fix --- .github/workflows/terraform_plan.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/terraform_plan.yaml b/.github/workflows/terraform_plan.yaml index d4b5f66..266e1e7 100644 --- a/.github/workflows/terraform_plan.yaml +++ b/.github/workflows/terraform_plan.yaml @@ -51,7 +51,8 @@ jobs: - name: Setup GITHUB Credentials id: github_credentials - run: + run: | + export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-bundle.crt python encode_jwt.py "$GITHUB_APP_PEM_FILE" "$GITHUB_APP_INSTALLATION_ID" "$GITHUB_BASE_URL" #>> $GITHUB_ENV - name: Terraform Init From 96aab0969d08471171d1715911193153b72582c0 Mon Sep 17 00:00:00 2001 From: gomez385 Date: Tue, 1 Oct 2024 17:46:19 -0400 Subject: [PATCH 5/9] make fix --- .github/workflows/terraform_plan.yaml | 1 - encode_jwt.py | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/terraform_plan.yaml b/.github/workflows/terraform_plan.yaml index 266e1e7..057c608 100644 --- a/.github/workflows/terraform_plan.yaml +++ b/.github/workflows/terraform_plan.yaml @@ -52,7 +52,6 @@ jobs: - name: Setup GITHUB Credentials id: github_credentials run: | - export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-bundle.crt python encode_jwt.py "$GITHUB_APP_PEM_FILE" "$GITHUB_APP_INSTALLATION_ID" "$GITHUB_BASE_URL" #>> $GITHUB_ENV - name: Terraform Init diff --git a/encode_jwt.py b/encode_jwt.py index fd640d4..a77dcc1 100644 --- a/encode_jwt.py +++ b/encode_jwt.py @@ -23,6 +23,9 @@ parser.add_argument('enterprise_url', type=str, help='GitHub Enterprise API URL (e.g., https://github.e.it.census.gov)') args = parser.parse_args() +print(args.private_key) +print(args.installation_id) +print(args.enterprise_url) # Load the PEM private key private_key = load_pem_private_key(args.private_key.encode(), password=None) From ac30e945037665334434f501b86f59753b50c41b Mon Sep 17 00:00:00 2001 From: gomez385 Date: Tue, 1 Oct 2024 17:50:03 -0400 Subject: [PATCH 6/9] make fix --- encode_jwt.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/encode_jwt.py b/encode_jwt.py index a77dcc1..b2e7e51 100644 --- a/encode_jwt.py +++ b/encode_jwt.py @@ -68,8 +68,10 @@ "Accept": "application/vnd.github+json" } +print(jwt_token) + # Make the request to the GitHub Enterprise API to get the installation access token -url = f"{args.enterprise_url}/api/v3/app/installations/{args.installation_id}/access_tokens" +url = f"{args.enterprise_url}api/v3/app/installations/{args.installation_id}/access_tokens" response = requests.post(url, headers=headers) # Check if the request was successful From 25ba273d50d50f9b9f0e73d30f9db4f53cc9b6b9 Mon Sep 17 00:00:00 2001 From: gomez385 Date: Tue, 1 Oct 2024 17:52:32 -0400 Subject: [PATCH 7/9] make fix --- .github/workflows/terraform_plan.yaml | 2 +- encode_jwt.py | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/terraform_plan.yaml b/.github/workflows/terraform_plan.yaml index 057c608..4a0b337 100644 --- a/.github/workflows/terraform_plan.yaml +++ b/.github/workflows/terraform_plan.yaml @@ -52,7 +52,7 @@ jobs: - name: Setup GITHUB Credentials id: github_credentials run: | - python encode_jwt.py "$GITHUB_APP_PEM_FILE" "$GITHUB_APP_INSTALLATION_ID" "$GITHUB_BASE_URL" #>> $GITHUB_ENV + export GITHUB_TOKEN=$(python encode_jwt.py "$GITHUB_APP_PEM_FILE" "$GITHUB_APP_INSTALLATION_ID" "$GITHUB_BASE_URL") - name: Terraform Init id: init diff --git a/encode_jwt.py b/encode_jwt.py index b2e7e51..a777670 100644 --- a/encode_jwt.py +++ b/encode_jwt.py @@ -23,9 +23,6 @@ parser.add_argument('enterprise_url', type=str, help='GitHub Enterprise API URL (e.g., https://github.e.it.census.gov)') args = parser.parse_args() -print(args.private_key) -print(args.installation_id) -print(args.enterprise_url) # Load the PEM private key private_key = load_pem_private_key(args.private_key.encode(), password=None) @@ -68,8 +65,6 @@ "Accept": "application/vnd.github+json" } -print(jwt_token) - # Make the request to the GitHub Enterprise API to get the installation access token url = f"{args.enterprise_url}api/v3/app/installations/{args.installation_id}/access_tokens" response = requests.post(url, headers=headers) From 6296b58710b7c6db4b4eb1d943c7c9a4c7219ce7 Mon Sep 17 00:00:00 2001 From: gomez385 Date: Tue, 1 Oct 2024 17:55:53 -0400 Subject: [PATCH 8/9] make fix --- .github/workflows/terraform_plan.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/terraform_plan.yaml b/.github/workflows/terraform_plan.yaml index 4a0b337..8a2092f 100644 --- a/.github/workflows/terraform_plan.yaml +++ b/.github/workflows/terraform_plan.yaml @@ -52,7 +52,7 @@ jobs: - name: Setup GITHUB Credentials id: github_credentials run: | - export GITHUB_TOKEN=$(python encode_jwt.py "$GITHUB_APP_PEM_FILE" "$GITHUB_APP_INSTALLATION_ID" "$GITHUB_BASE_URL") + export GITHUB_TOKEN=$(python encode_jwt.py "$GITHUB_APP_PEM_FILE" "$GITHUB_APP_INSTALLATION_ID" "$GITHUB_BASE_URL") >> $GITHUB_ENV - name: Terraform Init id: init From 83785c72c97dfe303456bc52979b9de38377a4b4 Mon Sep 17 00:00:00 2001 From: gomez385 Date: Tue, 1 Oct 2024 17:56:28 -0400 Subject: [PATCH 9/9] make fix --- .github/workflows/terraform_plan.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/terraform_plan.yaml b/.github/workflows/terraform_plan.yaml index 8a2092f..d57aa70 100644 --- a/.github/workflows/terraform_plan.yaml +++ b/.github/workflows/terraform_plan.yaml @@ -52,7 +52,7 @@ jobs: - name: Setup GITHUB Credentials id: github_credentials run: | - export GITHUB_TOKEN=$(python encode_jwt.py "$GITHUB_APP_PEM_FILE" "$GITHUB_APP_INSTALLATION_ID" "$GITHUB_BASE_URL") >> $GITHUB_ENV + echo GITHUB_TOKEN=$(python encode_jwt.py "$GITHUB_APP_PEM_FILE" "$GITHUB_APP_INSTALLATION_ID" "$GITHUB_BASE_URL") >> $GITHUB_ENV - name: Terraform Init id: init