From 2e88b66d84c8479d7060a919aa78e86941b16f6c Mon Sep 17 00:00:00 2001 From: Jason Lantz Date: Wed, 30 Oct 2024 18:46:24 -0500 Subject: [PATCH] Add reusable workflow to delete an org session * **Get GitHub Access Token**: Retrieve GitHub Access Token from the specified environment and store it in the GitHub environment variable. * **Delete Org Session**: Delete the org session from the specified environment using the retrieved GitHub Access Token. * **Add Job Summary**: Add a job summary to the GitHub step summary, including the environment name and status of the org session deletion. --- .github/workflows/delete-org-session.yml | 47 ++++++++++++++++++++++++ pyproject.toml | 1 - 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/delete-org-session.yml diff --git a/.github/workflows/delete-org-session.yml b/.github/workflows/delete-org-session.yml new file mode 100644 index 0000000..d73f8fe --- /dev/null +++ b/.github/workflows/delete-org-session.yml @@ -0,0 +1,47 @@ +name: Delete Org Session + +on: + workflow_call: + inputs: + environment_name: + description: "The name of the GitHub Environment to delete the org session from" + required: true + type: string + github_auth_environment: + description: "The name of the GitHub Environment to get the GitHub Access token from" + required: true + type: string + secrets: + github-token: + required: true + +jobs: + delete-org-session: + name: "Delete Org Session" + runs-on: ubuntu-latest + steps: + - name: Get GitHub Access Token + run: | + echo "Retrieving GitHub Access Token from environment: ${{ inputs.github_auth_environment }}" + GITHUB_ACCESS_TOKEN=$(gh api \ + -H "Authorization: token ${{ secrets.github-token }}" \ + "/repos/${{ github.repository }}/environments/${{ inputs.github_auth_environment }}/variables/GITHUB_ACCESS_TOKEN" \ + | jq -r '.value') + echo "GITHUB_ACCESS_TOKEN=${GITHUB_ACCESS_TOKEN}" >> $GITHUB_ENV + shell: bash + + - name: Delete Org Session + run: | + echo "Deleting org session from environment: ${{ inputs.environment_name }}" + gh api \ + -X DELETE \ + -H "Authorization: token ${{ env.GITHUB_ACCESS_TOKEN }}" \ + "/repos/${{ github.repository }}/environments/${{ inputs.environment_name }}/variables/ACCESS_TOKEN" + shell: bash + + - name: Add Job Summary + run: | + echo "## Org Session Deletion Summary" >> $GITHUB_STEP_SUMMARY + echo "Environment: ${{ inputs.environment_name }}" >> $GITHUB_STEP_SUMMARY + echo "Status: Org session deleted successfully" >> $GITHUB_STEP_SUMMARY + shell: bash diff --git a/pyproject.toml b/pyproject.toml index f969f71..5dce770 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,6 @@ requests = "^2.28.1" click = "^8.1.3" rich_click = "^1.0.0" pynacl = "^1.4.0" -cryptography = "^43.0.3" [tool.poetry.group.dev.dependencies] pytest = "^8.3.3"