Skip to content

Creates new package version whenever PR gets merged to dev branch #16

Creates new package version whenever PR gets merged to dev branch

Creates new package version whenever PR gets merged to dev branch #16

name: Create new package version
run-name: Creates new package version whenever PR gets merged to dev branch
on:
pull_request:
types: [closed]
branches:
- dev
paths:
- 'force-app/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checkout the Source code from the latest commit
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Installing NPM so that SFDX can be installed
- name: Installing NPM
run: npm install
# Install JQ
- name: Install JQ
run: sudo apt-get install jq
# Installing SFDX CLI
- name: Installing SFDX CLI
run: |
npm install @salesforce/cli --global
# Creating new .key for .crt file stored in the Connected App
- name: Creating .key file
run: |
touch server.key
echo -e "${{ secrets.SF_CICD_SERVERKEY }}" >> server.key
# Authorizing to DevHub
- name: Authorizing the DevHub
run: sf org login jwt --json --alias DevHub --set-default --set-default-dev-hub --username "${{ secrets.SF_CICD_USERNAME }}" --keyfile /home/runner/work/game-force/game-force/server.key --clientid ${{ secrets.SF_CLIENT_SECRET }}
# Creating a new Package version
- name: Creating a new Package version
run: |
JSON=$(sf package version create --target-dev-hub DevHub --package ${{ vars.SF_PKG_ID }} --installation-key ${{ secrets.SF_PKG_INSTALL_KEY }} --code-coverage --json --releasenotes-url ${{ vars.SF_RELEASE_NOTES_URL }} --json --wait 20);
STATUS=$(echo $JSON | jq '.result.Status');
ID=$(echo $JSON | jq -r '.result.Id');
# Promoting a new package version (removed since main branch will no longer be used)
# - name: Promoting a new package version
# run: |
# if [ $STATUS = "\"Success\"" ];
# then
# sf package version promote --package $ID
# else
# echo "Unable to promote package since package version create has failed";
# fi
# Listing all package versions
- name: List package versions
run: sf package version list