forked from salesagility/SuiteCRM
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvement - Acciones de Github - Adaptar Github Actions (#7)
- Loading branch information
1 parent
05a6ec9
commit 2f06c92
Showing
7 changed files
with
173 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 167 additions & 0 deletions
167
.github/workflows/Develop_ReinstallInstanceOnUserAction.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
name: Develop - Reinstall Instance on User Action | ||
on: | ||
workflow_dispatch: | ||
env: | ||
DEVELOP_HOST: ${{ secrets.DEVELOP_HOST}} | ||
DEVELOP_SSH_USERNAME: ${{ secrets.DEVELOP_SSH_USERNAME}} | ||
DEVELOP_DOMAIN_NAME: ${{ secrets.DEVELOP_DOMAIN_NAME}} | ||
MAIN_HOST: ${{ secrets.MAIN_HOST}} | ||
MAIN_SSH_USERNAME: ${{ secrets.MAIN_SSH_USERNAME}} | ||
jobs: | ||
reinstall_instance: | ||
name: Reinstall Instance on User Action | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Extract branch name | ||
run: echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} && echo 'BRANCH='${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} >> $GITHUB_ENV | ||
- name: Install SSH Key | ||
uses: shimataro/ssh-key-action@v2 | ||
with: | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
known_hosts: unnecessary | ||
- name: Adding Known Hosts Develop | ||
run: ssh-keyscan -H $DEVELOP_HOST >> ~/.ssh/known_hosts | ||
- name: Adding Known Hosts Main | ||
run: ssh-keyscan -H $MAIN_HOST >> ~/.ssh/known_hosts | ||
- name: Extract branch clean | ||
run: echo 'BRANCH_CLEAN='`echo ${{ env.BRANCH }} | sed -e 's/[^a-zA-Z0-9_/]//g'` >> $GITHUB_ENV | ||
- name: Get Develop instance database name | ||
run: echo 'DATABASE_NAME='`ssh $DEVELOP_SSH_USERNAME@$DEVELOP_HOST grep "db_name" /web/${{ env.BRANCH_CLEAN }}/config_override.php | sed "s/.*=.'//g" | sed "s/';.*//g"` >> $GITHUB_ENV | ||
- name: Set current date as env variable | ||
run: echo 'NOW='$(date +'%Y-%m-%d %H:%M:%S') >> $GITHUB_ENV | ||
- name: echo environment variables | ||
run: echo ${{ env }} | ||
# - name: Delete develop instance | ||
# run: ssh $DEVELOP_SSH_USERNAME@$DEVELOP_HOST "test -e /web/${{ env.BRANCH_CLEAN }}" && (echo "Directory branch exists" && ssh $DEVELOP_SSH_USERNAME@$DEVELOP_HOST "rm -rf /web/${{ env.BRANCH_CLEAN }} && mysql -h 127.0.0.1 -u $DEVELOP_DB_USERNAME --password=$DEVELOP_DB_PASSWORD -e 'drop database if exists ${{ env.DATABASE_NAME }}; create database ${{ env.DATABASE_NAME }};'") || echo "Branch doesn't exist in develop" | ||
- name: Create Instance in develop through Main | ||
run: ssh $MAIN_SSH_USERNAME@$MAIN_HOST "cd scripts/create && bash create.sh -b ${{ env.BRANCH }} -i $DEVELOP_DOMAIN_NAME -p /web/${{ env.BRANCH_CLEAN }} -db ${{ env.DATABASE_NAME }} -d -y" | ||
- name: Set Clean git branch | ||
run: ssh $DEVELOP_SSH_USERNAME@$DEVELOP_HOST "test -e /web/${{ env.BRANCH_CLEAN }}" && (echo "Directory branch exists" && ssh $DEVELOP_SSH_USERNAME@$DEVELOP_HOST "cd /web/${{ env.BRANCH_CLEAN }} && git stash && git reset && git pull") | ||
- name: Get project data | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
ORGANIZATION: SinergiaTIC | ||
PROJECT_NUMBER: 2 | ||
PR_ID: ${{ github.event.pull_request.node_id }} | ||
run: | | ||
gh api graphql -f query=' | ||
query($org: String!, $number: Int!) { | ||
organization(login: $org){ | ||
projectV2(number: $number) { | ||
id | ||
fields(first:20) { | ||
nodes { | ||
... on ProjectV2Field { | ||
id | ||
name | ||
} | ||
... on ProjectV2SingleSelectField { | ||
id | ||
name | ||
options { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
} | ||
items(first:100) { | ||
nodes { | ||
... on ProjectV2Item { | ||
id | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json | ||
echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV | ||
echo 'URL_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "URLValidationInstance") | .id' project_data.json) >> $GITHUB_ENV | ||
echo 'DB_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "DBValidationInstance") | .id' project_data.json) >> $GITHUB_ENV | ||
echo 'DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "DateValidationInstance") | .id' project_data.json) >> $GITHUB_ENV | ||
echo 'CURRENT_DATE='$(date +'%Y-%m-%d') >> $GITHUB_ENV | ||
- name: Get PR Item ID | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
PR_ID: ${{ github.event.pull_request.node_id }} | ||
run: | | ||
item_id="$( gh api graphql -f query=' | ||
mutation($project:ID!, $pr:ID!) { | ||
addProjectV2ItemById(input: {projectId: $project, contentId: $pr}) { | ||
item { | ||
id | ||
} | ||
} | ||
}' -f project=$PROJECT_ID -f pr=$PR_ID --jq '.data.addProjectV2ItemById.item.id')" | ||
echo 'ITEM_ID='$item_id >> $GITHUB_ENV | ||
- name: Change Fields | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
run: | | ||
gh api graphql -f query=' | ||
mutation ( | ||
$project: ID! | ||
$item: ID! | ||
$url_field: ID! | ||
$url_value: String! | ||
) { | ||
set_status: updateProjectV2ItemFieldValue(input: { | ||
projectId: $project | ||
itemId: $item | ||
fieldId: $url_field | ||
value: { | ||
text: $url_value | ||
} | ||
}) { | ||
projectV2Item { | ||
id | ||
} | ||
} | ||
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f url_field=$URL_FIELD_ID -f url_value=https://${{ env.DEVELOP_DOMAIN_NAME}}/${{ env.BRANCH_CLEAN }} --silent | ||
gh api graphql -f query=' | ||
mutation ( | ||
$project: ID! | ||
$item: ID! | ||
$db_field: ID! | ||
$db_value: String! | ||
) { | ||
set_status: updateProjectV2ItemFieldValue(input: { | ||
projectId: $project | ||
itemId: $item | ||
fieldId: $db_field | ||
value: { | ||
text: $db_value | ||
} | ||
}) { | ||
projectV2Item { | ||
id | ||
} | ||
} | ||
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f db_field=$DB_FIELD_ID -f db_value=${{ env.DATABASE_NAME }} --silent | ||
gh api graphql -f query=' | ||
mutation ( | ||
$project: ID! | ||
$item: ID! | ||
$date_field: ID! | ||
$date_value: Date! | ||
) { | ||
set_status: updateProjectV2ItemFieldValue(input: { | ||
projectId: $project | ||
itemId: $item | ||
fieldId: $date_field | ||
value: { | ||
date: $date_value | ||
} | ||
}) { | ||
projectV2Item { | ||
id | ||
} | ||
} | ||
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f date_field=$DATE_FIELD_ID -f date_value=$CURRENT_DATE --silent | ||
- name: Create or Edit PR comment | ||
uses: thollander/actions-comment-pull-request@v1 | ||
with: | ||
message: | | ||
Actions executed at: ${{ env.NOW }}. | ||
comment_includes: 'Actions executed at:' | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
name: Projects Move to release | ||
name: Projects - Move to release | ||
on: | ||
release: | ||
types: [published] | ||
|