This repository implements a Github Action that's is a variation of the Bitbucket Pipelines examples with org development.
This action is usefull to deploy to non-scratch orgs (sandbox or production) with Github Workflow.
It's a Javascript Github Action, that will once is executed will run the following steps:
- Download and install Salesforce CLI
- Decrypt the certificate
- Auth in the target sandbox/org
- Deploy/Check one or more deploy package
- Deploy/Check destructive changes (optional)
- Execute Data Factory Apex
Warning
This repository was cloned and updated from https://github.com/tiagonnascimento/sfdx-orgdev-build-deploy as this repository was not updated for two years, at the time of this writing. Some URLs, configuration and dependencies are deprecated or do not exist anymore.
-
If you intent to use it, please go through the Readme of the referred repo, make sure you understand the concept and execute the Getting Started (of the referred repo) steps #4, 5, 6 and 10
-
Also you will need to add the following Github Secrets on your github repository, that will be later used on your Github Workflow:
- CONSUMER_KEY: holds the client_id of the connected app that you created on step #4 of the referred repo
- USERNAME: holds the username that will be used to connect to the target org/sandbox
- DECRYPTION_KEY: holds the Key value you generated on step #6 of the referred repo - will be used to decrypt the certificate
- DECRYPTION_IV: holds the IV value you generated on step #6 of the referred repo - will be used to decrypt the certificate
You can execute the action as per the following sample:
# Unique name for this workflow
name: On push develop - Deploy to TI01
# Definition when the workflow should run
on:
push:
branches:
- develop
# Jobs to be executed
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
# Checkout the code in the pull request
- name: 'Checkout source code'
uses: actions/checkout@v2
- name: 'Build and Deploy'
uses: tiagonnascimento/sfdx-orgdev-build-deploy@v2
with:
type: 'sandbox'
certificate_path: devops/server.key.enc
decryption_key: ${{ secrets.DECRYPTION_KEY_NON_PRODUCTIVE }}
decryption_iv: ${{ secrets.DECRYPTION_IV_NON_PRODUCTIVE }}
client_id: ${{ secrets.CONSUMER_KEY_TI01 }}
username: ${{ secrets.USERNAME_TI01 }}
checkonly: false
deploy_wait_time: '10'
manifest_path: manifest/package-01.xml,manifest/package-02.xml,manifest/package-03.xml
destructive_path: destructive
data_factory: scripts/apex/CreateBaseData.apex
default_source_path: force-app/main/default
Name | Requirement | Description |
---|---|---|
type |
required | Whether to deploy on production or on sandbox (default value) |
certificate_path |
required | Path on the repo where the encrypted certificate is stored |
decryption_key |
required | Decryption KEY to be used to decrypt the certificate |
decryption_iv |
required | Decryption IV to be used to decrypt the certificate |
client_id |
required | Client ID that will be used to connect into the target org/sandbox |
username |
required | Username that will be used to connect into the target org/sandbox |
checkonly |
required | Boolean value to indicate whether this action should execute the deploy or only check it, default is false, but if true it will add -c parameter on the force:mdapi:deploy commands |
manifest_path |
required | Path on the current repository (or on the root folder of the sfdx project if sfdx_root_folder is set) to one or more package.xml that represents the packages to be deployed. Based on this files the metadata package will be created and deployed in the order specified. Ex: |
sfdx_root_folder |
optional | Path on the current repository to the root folder of sfdx folder. Ex: sfdx_project |
deploy_testlevel |
optional | TestLevel applied on the deploy. Default is RunLocalTests . If specified RunSpecifiedTests , the action will execute only the classes mentioned in the manifest file that contains @isTest tag |
deploy_wait_time |
optional | Wait time for deployment to finish in minutes. Default is 60 |
destructive_path |
optional | Path on the repo where the destructive changes directory is - if not informed, it's not executed |
data_factory |
optional | Path on the repo where an APEX script used as a data factory is stored. if not informed, it's not executed |
default_source_path |
optional | Path on the repo where your source files are stored, for SFDX project this is normally force-app/main/default |
The destructive_path
input is a path folder, with two files inside. For example if we have the following folder structure
|-- config
|-- devops
|-- force-app
|-- manifest
|-- releases
|-- 01_releases
|-- destructive
|-- package.xml
|-- destructiveChanges.xml
|-- scripts
|-- .forceignore
|-- .gitignore
...
|-- sfdx-project.json
The destructive_path
will be releases/01_releases/destructive
.
If you find any issues or opportunities for improving this repository, fix them! Feel free to contribute to this project by forking this repository and making changes to the content. Once you've made your changes, share them back with the community by sending a pull request. See How to send pull requests for more information about contributing to GitHub projects.
Update to the Github action code should be compiled and the distribution artifact (dist/index.js
) should be added to the repository (according to the Documentation of Github)
To do so, follow the following steps:
- Install
vercel/ncc by
running this command in your terminal.
npm i -g @vercel/ncc
- Install dependencies
npm ci
- Compile your
index.js
file, after entering thesrc
directory
cd src
ncc build index.js --license licenses.txt --out ../dist
You'll see a new dist/index.js
file, at the root of the repository folder, with your code and the compiled modules. You will also see an accompanying dist/licenses.txt
file containing all the licenses of the node_modules
you are using.
Change the main
keyword in your action.yml
file to use the new dist/index.js
file.
main: 'dist/index.js'
-
Commit
dist/index.js
alongside your updated files.git add dist/index.js action.yml ... git commit -m "..."
If you find any issues with this demo that you can't fix, feel free to report them in the issues section of this repository.