-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reusable workflow to delete environment and revoke Salesforce token
Add a new reusable workflow to delete an environment and revoke the Salesforce token. * **New Workflow**: Add `delete-environment.yml` to `.github/workflows/` to delete an environment and revoke the Salesforce token. - Include steps to authenticate to DevHub, delete the environment, and revoke the Salesforce token using new d2x commands. * **New Command**: Add `revoke_sf_token` function in `d2x/auth/sf/auth_url/__init__.py` to handle token revocation. - Implement the function to make API calls to Salesforce for token revocation. - Add necessary imports for the new function. * **Documentation**: Update `README.md` to document the new workflow and command with usage instructions. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/muselab-d2x/d2x/tree/cumulusci-next-snapshots?shareId=XXXX-XXXX-XXXX-XXXX).
- Loading branch information
Showing
3 changed files
with
229 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Delete Environment | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
env-name: | ||
required: true | ||
type: string | ||
sf-auth-url: | ||
required: true | ||
type: string | ||
secrets: | ||
dev-hub-auth-url: | ||
required: true | ||
github-token: | ||
required: true | ||
|
||
jobs: | ||
delete-environment: | ||
name: "Delete Environment" | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ghcr.io/muselab-d2x/d2x:cumulusci-next | ||
options: --user root | ||
credentials: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.github-token }} | ||
env: | ||
DEV_HUB_AUTH_URL: "${{ secrets.dev-hub-auth-url }}" | ||
CUMULUSCI_SERVICE_github: '{ "username": "${{ github.actor }}", "token": "${{ secrets.github-token }}", "email": "NOTUSED" }' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Auth to DevHub | ||
run: /usr/local/bin/devhub.sh | ||
|
||
- name: Delete Environment | ||
run: cci org scratch_delete ${{ inputs.env-name }} | ||
shell: bash | ||
|
||
- name: Revoke Salesforce Token | ||
run: | | ||
python -c " | ||
import os | ||
from d2x.auth.sf.auth_url import revoke_sf_token | ||
from rich.console import Console | ||
|
||
console = Console() | ||
sf_auth_url = os.environ.get('SF_AUTH_URL') | ||
access_token = os.environ.get('ACCESS_TOKEN') | ||
instance_url = os.environ.get('INSTANCE_URL') | ||
|
||
revoke_sf_token(instance_url, access_token, console) | ||
" | ||
env: | ||
SF_AUTH_URL: ${{ inputs.sf-auth-url }} | ||
ACCESS_TOKEN: ${{ steps.auth_to_devhub.outputs.access_token }} | ||
INSTANCE_URL: ${{ steps.auth_to_devhub.outputs.instance_url }} |
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