Skip to content

Commit b07b55d

Browse files
feat(#478): ✨ WIP add possibility to execute single steps
Signed-off-by: Andy Augustin <[email protected]>
1 parent cafbaa5 commit b07b55d

File tree

3 files changed

+57
-19
lines changed

3 files changed

+57
-19
lines changed

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ ADD src/*.sh /bin/
2727
RUN chmod +x /bin/entrypoint.sh \
2828
&& chmod +x /bin/sync_template.sh \
2929
&& chmod +x /bin/sync_common.sh \
30-
&& chmod +x /bin/gpg_no_tty.sh \
31-
&& chmod +x /bin/cli.sh
30+
&& chmod +x /bin/gpg_no_tty.sh
3231

3332
RUN mkdir -p /root/.ssh \
3433
&& ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,34 @@ jobs:
395395
396396
```
397397

398+
## Lifecycle actions
399+
400+
The action has different phases which are executed in the following order
401+
402+
* **preparation** prepare and configure git related things
403+
* init git
404+
* auth related (ssh or github auth)
405+
* [optional] gpg setup
406+
* **prechecks** run some prechecks
407+
* skipped if `is_force_push_pr` parameter is set to `true`
408+
* check if the sync branch is already existing in target repository
409+
* check if new changes of the source repository are already within history
410+
* **pull** pull the changes from the remote repository into the action runtime
411+
* **commit** commit the changes within the action runtime
412+
* **push**
413+
* if `is_force_push_pr` is set to true then a force push will be executed
414+
* **pr**
415+
* eventual create registered labels (:ninja: emojis are supported)
416+
* create a new PR
417+
* if `is_force_push_pr` is set to true then the PR will be created or edited
418+
* [optional] **cleanup** eventual cleanup older PRs of the action
419+
* set **github action outputs**
420+
421+
If `is_dry_run` parameter is set to true then all stages modifying the github state are not run (e.g. push, cleanup and pr).
422+
423+
It is possible to run a subset of the mentioned lifecycle actions.
424+
**preparation** and **github action outputs** will be run every time.
425+
398426
## Lifecycle hooks
399427

400428
Different lifecycle hooks are supported. You need to enable the functionality with the option `is_allow_hooks` and set it to `true`

src/sync_template.sh

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ function handle_templatesyncignore() {
372372
# Logic
373373
#######################################################
374374

375-
function prechecks() {
375+
function arr_prechecks() {
376376
info "prechecks"
377377
echo "::group::prechecks"
378378
if [ "${IS_FORCE_PUSH_PR}" == "true" ]; then
@@ -387,7 +387,7 @@ function prechecks() {
387387
}
388388

389389

390-
function checkout_branch_and_pull() {
390+
function arr_checkout_branch_and_pull() {
391391
info "checkout branch and pull"
392392
cmd_from_yml "prepull"
393393

@@ -409,7 +409,7 @@ function checkout_branch_and_pull() {
409409
}
410410

411411

412-
function commit() {
412+
function arr_commit() {
413413
info "commit"
414414

415415
cmd_from_yml "precommit"
@@ -428,7 +428,20 @@ function commit() {
428428
}
429429

430430

431-
function push_prepare_pr_create_pr() {
431+
function arr_push() {
432+
info "push"
433+
434+
echo "::group::push"
435+
if [ "$IS_DRY_RUN" == "true" ]; then
436+
warn "dry_run option is set to on. skipping push"
437+
return 0
438+
fi
439+
cmd_from_yml "prepush"
440+
push "${PR_BRANCH}" "${IS_FORCE_PUSH_PR}"
441+
echo "::endgroup::"
442+
}
443+
444+
function arr_push_prepare_pr_create_pr() {
432445
info "push_prepare_pr_create_pr"
433446
if [ "$IS_DRY_RUN" == "true" ]; then
434447
warn "dry_run option is set to on. skipping labels check, cleanup older PRs, push and create pr"
@@ -456,8 +469,6 @@ function push_prepare_pr_create_pr() {
456469

457470
echo "::group::push changes and create PR"
458471

459-
cmd_from_yml "prepush"
460-
push "${PR_BRANCH}" "${IS_FORCE_PUSH_PR}"
461472
cmd_from_yml "prepr"
462473
if [ "$IS_FORCE_PUSH_PR" == true ] ; then
463474
create_or_edit_pr "${PR_TITLE}" "${PR_BODY}" "${UPSTREAM_BRANCH}" "${PR_LABELS}" "${PR_REVIEWERS}"
@@ -471,16 +482,16 @@ function push_prepare_pr_create_pr() {
471482

472483
declare -A arr
473484

474-
arr["pull"]=checkout_branch_and_pull
475-
arr["commit"]=commit
476-
arr["pr"]=push_prepare_pr_create_pr
477-
478-
prechecks
479-
480-
checkout_branch_and_pull
481-
482-
commit
483-
484-
push_prepare_pr_create_pr
485+
arr["prechecks"]=arr_prechecks
486+
arr["pull"]=arr_checkout_branch_and_pull
487+
arr["commit"]=arr_commit
488+
arr["push"]=arr_push
489+
arr["pr"]=arr_push_prepare_pr_create_pr
490+
491+
${arr["prechecks"]}
492+
${arr["pull"]}
493+
${arr["commit"]}
494+
${arr["push"]}
495+
${arr["pr"]}
485496

486497
set_github_action_outputs "${PR_BRANCH}" "${TEMPLATE_GIT_HASH}"

0 commit comments

Comments
 (0)