Task/sfi 837 automate package version creation #2
Workflow file for this run
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
name: Release - Package Version Creation | |
on: | |
pull_request: | |
branches: | |
- 'release/*' | |
- 'Release/*' | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
env: | |
PBO_AUTH_URL: ${{ secrets.PBO_AUTH_URL }} | |
steps: | |
- name: Checkout This Repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Install jq | |
run: sudo apt-get install jq | |
- name: Verify And Update App Version | |
run: script/update-app-info-version.sh | |
- name: Install Salesforce CLI | |
run: npm install @salesforce/cli --global | |
- name: Create authentication file from secret | |
run: echo ${PBO_AUTH_URL} > secret.json | |
- name: Authenticate to Dev Hub | |
run: sf org login sfdx-url -f secret.json --set-default-dev-hub | |
- name: Create Package Version | |
run: | | |
PACKAGE_VERSION_ID=$(sf package version create -p "Adyen Salesforce Order Management" -c -k Payments@Adyen -w 10 --json | jq -r '.result.Id') | |
echo "PACKAGE_VERSION_ID=$PACKAGE_VERSION_ID" >> $GITHUB_ENV | |
- name: Poll for Package Creation Status | |
run: | | |
while true; do | |
STATUS=$(sf package version report --package "$PACKAGE_VERSION_ID" --json | jq -r '.result.Status') | |
if [ "$STATUS" == "Success" ]; then | |
echo "Package creation completed successfully." | |
break | |
elif [ "$STATUS" == "Error" ]; then | |
echo "Package creation failed." | |
exit 1 | |
else | |
echo "Package creation is in progress. Current status: $STATUS" | |
fi | |
# Wait for 2 minutes before checking again | |
sleep 120 | |
done | |
- name: Commit Modified Files | |
run: | | |
git config --global user.name 'GitHub Actions' | |
git config --global user.email '[email protected]' | |
git add sfdx-project.json | |
git commit -m "chore: Update sfdx-project.json with new package version id: $PACKAGE_VERSION_ID" | |
git push origin "$GITHUB_REF" |