Skip to content

Commit

Permalink
Merge branch 'cumulusci-next-snapshots' of github.com:muselab-d2x/d2x…
Browse files Browse the repository at this point in the history
… into cumulusci-next-snapshots
  • Loading branch information
jlantz committed Oct 31, 2024
2 parents 9cb0622 + 3de3337 commit cebc4a0
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 49 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/beta-test-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
required: true
default: 1GP Packaging Beta
type: string

run-test:
description: If true, run the ci_beta flow to test the beta as part of the job. Set to false to split ci_beta into a separate workflow
default: true
type: boolean
debug:
required: false
default: false
Expand All @@ -20,6 +25,11 @@ on:
required: true
github-token:
required: true
github-app-id:
required: false
github-app-key:
required: false


jobs:
beta-test:
Expand All @@ -36,6 +46,10 @@ jobs:
DEV_HUB_AUTH_URL: "${{ secrets.dev-hub-auth-url }}"
PACKAGING_ORG_AUTH_URL: "${{ secrets.packaging-org-auth-url }}"
CUMULUSCI_SERVICE_github: '{ "username": "${{ github.actor }}", "token": "${{ secrets.github-token }}", "email": "${{ secrets.gh-email }}" }'

GITHUB_APP_ID: "${{ secrets.github-app-id }}"
GITHUB_APP_KEY: "${{ secrets.github-app-key }}"

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -47,9 +61,10 @@ jobs:
run: cci flow run release_beta --org packaging $([[ "${{ inputs.debug }}" == "true" ]] && echo " --debug")
shell: bash
- name: Run Beta Test
if: ${{ inputs.run-test }}
run: cci flow run ci_beta --org beta
- name: Delete Scratch Org
if: ${{ always() }}
if: ${{ always() }} && ${{ inputs.run-test }}
run: |
cci org scratch_delete beta
shell: bash
50 changes: 50 additions & 0 deletions .github/workflows/beta-test-scratch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Beta Test

on:
workflow_call:
inputs:
debug:
required: false
default: false
type: boolean
secrets:
dev-hub-auth-url:
required: true
gh-email:
required: true
github-token:
required: true
github-app-id:
required: false
github-app-key:
required: false

jobs:
beta-test:
name: "Beta Test in Scratch Org"
runs-on: ubuntu-latest
environment: ${{ inputs.env-name }}
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 }}"
PACKAGING_ORG_AUTH_URL: "${{ secrets.packaging-org-auth-url }}"
CUMULUSCI_SERVICE_github: '{ "username": "${{ github.actor }}", "token": "${{ secrets.github-token }}", "email": "${{ secrets.gh-email }}" }'
GITHUB_APP_ID: "${{ secrets.github-app-id }}"
GITHUB_APP_KEY: "${{ secrets.github-app-key }}"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Auth to DevHub
run: /usr/local/bin/devhub.sh
- name: Run Beta Test
run: cci flow run ci_beta --org beta
- name: Delete Scratch Org
if: ${{ always() }}
run: |
cci org scratch_delete beta
shell: bash
10 changes: 10 additions & 0 deletions .github/workflows/beta-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ on:
github-token:
required: true

github-app-id:
required: false
github-app-key:
required: false


jobs:
beta-test:
name: "Beta Test"
Expand All @@ -26,6 +32,10 @@ jobs:
DEV_HUB_AUTH_URL: "${{ secrets.dev-hub-auth-url }}"
PACKAGING_ORG_AUTH_URL: "${{ secrets.packaging-org-auth-url }}"
CUMULUSCI_SERVICE_github: '{ "username": "${{ github.actor }}", "token": "${{ secrets.github-token }}", "email": "${{ secrets.gh-email }}" }'

GITHUB_APP_ID: "${{ secrets.github-app-id }}"
GITHUB_APP_KEY: "${{ secrets.github-app-key }}"

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/investigate-1gp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ jobs:
cci task run dx_convert_from
fi
shell: bash
- name: Prepare Managed Source
run: cci task run create_managed_src
#- name: Prepare Managed Source
# run: cci task run create_managed_src
- name: Update Package XML for Packaged Deploy
run: cci task run update_package_xml
- name: Validate-Only Deploy with Tests to Packaging Org
run: cci task run deploy --org packaging --path src --check-only True
#- name: Validate-Only Deploy with Tests to Packaging Org
# run: cci task run deploy --org packaging --path src --check-only True
- name: Dry Run of uninstall_packaged_incremental
run: cci task run uninstall_packaged_incremental --org packaging --dry-run True
177 changes: 136 additions & 41 deletions .github/workflows/org-login-slack.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,140 @@
name: Org Login URL to Slack DM
# File: .github/workflows/request-login-url.yml

name: Request Org Login URL

on:
workflow_call:
inputs:
environment:
description: The name of the environment
required: true
type: string
slack_username:
description: Slack username to send the login URL
required: true
type: string
secrets:
slack-bot-token:
required: true
github-token:
required: true
workflow_call:
inputs:
org:
description: "The name of the org to get the login URL for. NOTE: Do not select orgs starting with 'Snapshot:'"
required: true
type: string
slack_username:
description: "The Slack username to send the DM to"
required: true
type: string
environment:
description: "Select the environment to use (e.g., DevHub)"
required: true
type: environment
secrets:
SFDX_AUTH_URL:
description: "Salesforce DX Auth URL"
required: true
SLACK_BOT_TOKEN:
description: "Slack Bot Token"
required: true

jobs:
d2x-login-url:
name: Use d2x to generate a login url
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- run: pip install d2x

- name: Generate Login URL for ${{ github.event.inputs.environment }}
env:
AUTH_URL: ${{ secrets.sfdx-auth-url }}
run: python -m d2x.auth.sf.login_url > login_url.txt

- name: Send Slack DM
env:
SLACK_BOT_TOKEN: ${{ secrets.slack-bot-token }}
run: |
echo "login_url=$(cat login_url.txt)" >> $GITHUB_OUTPUT
rm login_url.txt
curl -X POST -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"channel": "@${{ github.event.inputs.slack_username }}",
"text": "Here'"'"'s your Salesforce login URL for ${{ github.event.inputs.environment }}: ${{ steps.read_url.outputs.login_url }}"
}' \
https://slack.com/api/chat.postMessage
send-login-url:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Check SFDX_AUTH_URL
run: |
if [ -z "${{ secrets.SFDX_AUTH_URL }}" ]; then
echo "Error: SFDX_AUTH_URL is not set."
exit 1
fi
- name: Cache d2x
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install d2x
run: |
pip install git+https://github.com/muselab-d2x/d2x.git@jlantz/update-auth-structure
d2x --version
- id: generate_login_url
name: Generate Login URL
env:
SFDX_AUTH_URL: ${{ secrets.SFDX_AUTH_URL }}
run: |
set -eo pipefail
# Generate the login URL and store it in a variable
login_url=$(d2x sf auth login | tail -1)
# Store the login URL in a temporary file (do not print it)
echo "$login_url" > login_url.txt
- name: Send Slack DM
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
ORG: ${{ inputs.org }}
SLACK_USERNAME: ${{ inputs.slack_username }}
run: |
set -e
# Validate inputs
if [ -z "$ORG" ] || [ -z "$SLACK_USERNAME" ]; then
echo "Error: ORG and SLACK_USERNAME must be provided."
exit 1
fi
# Read the login URL from the file (do not print it)
login_url=$(cat login_url.txt)
# Clean up the login URL file immediately
rm login_url.txt
# Retrieve the user ID based on the Slack username
USER_INFO=$(curl -s -X POST -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "username=$SLACK_USERNAME" \
https://slack.com/api/users.lookupByUsername)
USER_ID=$(echo "$USER_INFO" | jq -r '.user.id')
if [ "$USER_ID" == "null" ] || [ -z "$USER_ID" ]; then
error_message=$(echo "$USER_INFO" | jq -r '.error')
echo "Error: Failed to retrieve Slack user ID - $error_message"
exit 1
fi
# Construct the Slack message (do not print the login URL)
TEXT="Here is your Salesforce login URL for ${ORG}."
# Send the login URL as a private message
JSON_DATA=$(jq -n \
--arg channel "$USER_ID" \
--arg text "$TEXT" \
--arg login_url "$login_url" \
'{
channel: $channel,
text: $text,
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: $text
}
},
{
type: "section",
text: {
type: "mrkdwn",
text: "<\($login_url)|Click here to log in>"
}
}
]
}')
# Send the message via Slack API
response=$(curl -s -X POST -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
-H "Content-Type: application/json" \
-d "$JSON_DATA" \
https://slack.com/api/chat.postMessage)
# Enhanced error handling
if [[ $(echo "$response" | jq -r '.ok') != "true" ]]; then
error_message=$(echo "$response" | jq -r '.error')
echo "Error: Failed to send Slack DM - $error_message"
exit 1
fi
echo "Slack message sent successfully."
23 changes: 20 additions & 3 deletions .github/workflows/release-1gp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ on:
required: false
description: "The name of the release to upload to the production org."
type: string
skip-deploy:
required: false
description: If true, don't deploy to the packaging org. Just release what's in the org currently
type: boolean
default: false
skip-test:
required: false
description: If true, don't test the package. Just upload and pass the build if the upload and GitHub Release are created successfully
type: boolean
default: false
secrets:
dev-hub-auth-url:
required: true
Expand Down Expand Up @@ -36,15 +46,22 @@ jobs:
uses: actions/checkout@v4
- name: Auth to DevHub
run: /usr/local/bin/devhub.sh
- name: Report Inputs
run: |
echo "Release Name: ${{ inputs.release-name }}" | tee -a "${GITHUB_STEP_SUMMARY}"
echo 'Command: cci flow run release_production --org packaging $([[ "${{ inputs.release-name }}" ]] && echo " -o upload_production__version_name_template \${{ inputs.release-name }}")' | tee -a "${GITHUB_STEP_SUMMARY}"
- name: Deploy to Packaging Org
if: ${{ inputs.skip-deploy == false }}
run: cci flow run ci_master --org packaging
- name: Build Production Package
run: cci flow run release_production --org packaging $([[ "${{ inputs.release-name }}" ]] && echo " -o upload_production__name ${{ inputs.release-name }}")
run: |
cci flow run release_production --org packaging $([[ "${{ inputs.release-name }}" ]] && echo " -o upload_production__version_name_template ${{ inputs.release-name }}")
shell: bash
- name: Run Beta Test
- name: Run Release Test in Scratch Org
if: ${{ inputs.skip-test == false }}
run: cci flow run ci_release --org release
- name: Delete Scratch Org
if: ${{ always() }}
if: ${{ always() }} && ${{ inputs.skip-test == false }}
run: |
cci org scratch_delete release
shell: bash

0 comments on commit cebc4a0

Please sign in to comment.