Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update makefile with create_scratch and up #39

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
name: Validate PR on develop branch
name: Validate pull request

on:
pull_request:
branches:
- main
types: [opened, synchronize]
paths:
- 'force-app/**'

jobs:
validate-deployment-on-develop-org:
validate-deployment:
runs-on: ubuntu-latest
container:
image: salesforce/cli:latest-slim
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- name: 'Checkout source code'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy project for Release
name: Deploy project

on:
release:
Expand All @@ -9,18 +9,17 @@ jobs:
runs-on: ubuntu-latest
container:
image: salesforce/cli:latest-slim
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- name: 'Checkout source code'
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: 'Authenticate using SF_ACCESS_TOKEN'
- name: 'Authenticate using SFDX_AUTH_URL'
shell: bash
run: |
echo ${{ secrets.SFDX_AUTH_URL }} | sf org login sfdx-url -s -a dev -u

- name: 'Validate'
- name: 'Deploy'
run: |
sf project deploy start -d force-app/ -c -l RunLocalTests -w 30 -o dev
30 changes: 25 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
.PHONY: create open push pull diff test apex_trigger
.PHONY: up create_scratch push pull diff test apex_trigger
TIMESTAMP := $(shell date +%s)
DEVHUB := devHub # update to be the alias of your dev hub that scratch orgs will be created from

create:
@sf org create scratch -f config/project-scratch-def.json -a $(ORG) -d -w 30
# attempt to open the current default org
# if it fails then try to create a new scratch org
# if that fails, then create org shape and try again
up:
@if ! sf org open ; then \
if ! sf org create scratch -f config/project-scratch-def.json -a "org-$(TIMESTAMP)" -d -w 30; then \
sf org create shape -o $(DEVHUB); \
sf org create scratch -f config/project-scratch-def.json -a "org-$(TIMESTAMP)" -d -w 30; \
sf org open; \
fi \
fi

open:
@sf org open
# create a scratch org with a given name, if not given then give a default name
# example: $ make create_scratch NAME=new-scratch-org
create_scratch:
@if [ ! -z $(NAME) ]; then \
sf org create scratch -f config/project-scratch-def.json -a $(NAME) -d -w 30; \
else \
sf org create scratch -f config/project-scratch-def.json -a "org-$(TIMESTAMP)" -d -w 30; \
fi; \
sf org open;

push:
@sf project deploy start --ignore-conflicts
Expand All @@ -19,6 +37,8 @@ diff:
test:
@sf apex run test --test-level RunLocalTests -y -w 30

# given a list of comma separated salesforce objects, create an apex trigger, a handler class, a helper class, and a custom settings
# example: $ make apex_trigger TARGET="Account,Contact,Opportunity"
apex_trigger:
@if [ ! -z $(TARGET) ]; then \
for sobj in $$(echo $(TARGET) | tr ',' '\n'); \
Expand Down
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Scratch Orgs are temporary Salesforce environments that are used for development
- Ideally, you'll do this during setup to get all metadata from sfdc repo into the scratch org

# Validate and Deploy
- Implements workflows from [k-capehart/sfdc-github-actions](https://github.com/k-capehart/sfdc-github-actions)
- .github/workflows/main.yml validates the package when a PR is opened
- .github/workflows/release.yml deploys the package when a Release is published
- Salesforce authorization URL is stored in Github Repository Secret
Expand All @@ -34,18 +35,18 @@ Scratch Orgs are temporary Salesforce environments that are used for development
- `validate()`: Executes before afterInsert() and afterUpdate().

# Makefile
| Command | Description|
| Command | Description |
| :-------------------------- | :----------------------|
| `make create ORG=[alias]` | Make scratch org.
| `make open` | Open default org.
| `make push` | Deploy local changes.
| `make pull` | Retrieve changes from org.
| `make diff` | Display diff between local and org.
| `make test` | Run apex tests and wait for result.
| `make up` | Attempt to open default org, if it fails then create a new scratch org.
| `make create_scratch` | Make scratch org.
| `make push` | Deploy local changes.
| `make pull` | Retrieve changes from org.
| `make diff` | Display diff between local and org.
| `make test` | Run apex tests and wait for result.
| `make apex_trigger TARGET=[Comma separated list of SObjects]` | Create Apex trigger, handler class, helper class, test class, and custom setting

# sf cli commands
| Command | Description |
| Command | Description |
| :---------------------------- | :------------------------- |
| `sf org open` | Open your default org in a browser.
| `sf project deploy preview` | Preview a deployment to see what will deploy to the org, the potential conflicts, and the ignored files.
Expand All @@ -56,8 +57,10 @@ Scratch Orgs are temporary Salesforce environments that are used for development
| `sf search` | Search for a command.
| `sf scanner run` | Scan a codebase with a selection of rules
| `sf org create shape` | Create a scratch org configuration (shape) based on the specified source org.
| `sf org list shape` | List all org shapes you’ve created.
| `sf org login web` | Log in to a Salesforce org using the web server flow.
| `sf org login sfdx-url` | Authorize and org using a SFdX Authorization URl in a file or through stdin.
| `sf org create scratch` | Create a scratch org.
| `sf org delete scratch` | Delete a scratch org.
| `sf org display` | Display information about an org. Use --verbose to display the sfdxAuthUrl property.
| `sf auth sfdxurl store` | Authorize an org using a Salesforce DX authorization URL stored in a file.
| `sf apex run test` | Invoke Apex tests in an org.