Skip to content

Commit

Permalink
Remove unnecessary branch filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariam Maarouf committed Feb 1, 2019
1 parent 5c997cb commit 0ff0e5d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ Stored as secrets or env vars, doesn't matter. But also please don't put your AW
- Function name - `my-function`
- Function ARN - `arn:aws:lambda:us-west-2:123456789012:function:my-function`
- Partial ARN - `123456789012:function:my-function`
- `BRANCH` (optional)
If the action should only be executed on a certain branch (e.g. `master`).


### Example workflow
```hcl
Expand All @@ -31,6 +30,7 @@ workflow "Build & deploy" {
}
action "py-lambda-deploy" {
needs = "Master"
uses = "mariamrf/py-lambda-action@master"
secrets = [
"AWS_ACCESS_KEY_ID",
Expand All @@ -39,8 +39,12 @@ action "py-lambda-deploy" {
"LAMBDA_FUNCTION_NAME",
"LAMBDA_LAYER_ARN",
]
env = {
BRANCH = "master"
}
}
# Filter for master branch
action "Master" {
uses = "actions/bin/filter@master"
args = "branch master"
}
```
11 changes: 0 additions & 11 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
#!/bin/bash

check_if_branch(){
local ref=$(jq '.ref' $GITHUB_EVENT_PATH)
if ! [[ -z ${BRANCH} ]]; then
if [ "$ref" != "\"refs/heads/$BRANCH\"" ]; then
echo "Not deploying because we're not on $BRANCH"
exit 0
fi
fi
}

install_zip_dependencies(){
echo "Installing and zipping dependencies..."
mkdir python
Expand Down Expand Up @@ -43,6 +33,5 @@ deploy_lambda_function(){
update_function_layers
}

check_if_branch
deploy_lambda_function
echo "Done."

0 comments on commit 0ff0e5d

Please sign in to comment.