Skip to content

Instantly share code, notes, and snippets.

View trylix's full-sized avatar

Brendenson Andrade trylix

View GitHub Profile
- name: Schedule Cleanup
run: |
aws events put-rule \
--name "CleanupBranch-${{ github.ref_name }}" \
--schedule-expression "rate(6 hours)" # Ajuste o tempo conforme necessário
aws events put-targets \
--rule "CleanupBranch-${{ github.ref_name }}" \
--targets "Id"="1","Arn"="arn:aws:lambda:us-east-1:123456789012:function:YourCleanupFunction","Input"="{\"branch_name\":\"${{ github.ref_name }}\",\"cluster_name\":\"my-cluster-name\",\"listener_arn\":\"arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/7c7a56b0\"}"
{
"source": ["custom.branchDeploy"],
"detail-type": ["ECS Deploy Expiration"],
"resources": [],
"detail": {
"branch_name": "feature-branch",
"cluster_name": "my-cluster-name",
"listener_arn": "arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/7c7a56b0"
}
}
import boto3
ecs_client = boto3.client('ecs')
elbv2_client = boto3.client('elbv2')
def lambda_handler(event, context):
branch_name = event['branch_name']
cluster_name = event['cluster_name']
service_name = f"my-service-{branch_name}"
listener_arn = event['listener_arn']
name: Deploy to ECS
on:
push:
branches:
- '*'
jobs:
deploy:
runs-on: ubuntu-latest
#!/bin/sh
# copy the “prepare commit msg” script to the proper hooks folder and fix the permission on that folder
# just run the script and on the next commit you will see the jira prefix
curl https://gist.githubusercontent.com/trylix/38e43750deedf3d83f13e6392904aed1/raw/0658f176f79d3b57e22141d5fd50681ff5b1498d/prepare-commit-msg.sh > .git/hooks/prepare-commit-msg && chmod u+x .git/hooks/prepare-commit-msg
@trylix
trylix / prepare-commit-msg.sh
Last active March 2, 2022 16:29
git prepare-commit-msg hook for automatically prepending an issue key from the start of the current branch name to commit messages.
#!/bin/sh
# check if commit is merge commit or a commit ammend
if [ $2 = "merge" ] || [ $2 = "commit" ]; then
exit
fi
ISSUE_KEY=`git branch | grep -o "\* \(.*/\)*[A-Z]\{2,\}-[0-9]\+" | grep -o "[A-Z]\{2,\}-[0-9]\+"`
if [ $? -ne 0 ]; then
# no issue key in branch, use the default message
exit
@trylix
trylix / settings.json
Last active March 25, 2021 13:33
VS Code Settings
{
"editor.fontFamily": "Fira Code",
"editor.fontSize": 14,
"editor.fontLigatures": true,
"editor.fontWeight": 300,
"editor.lineHeight": 28,
"editor.suggestSelection": "first",
"editor.parameterHints.enabled": false,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,