Merge to the next release branch not trigger subsequent action
According to https://github.community/t/push-from-action-does-not-trigger-subsequent-action/16854
:
An action pushes code using the repository’s GITHUB_TOKEN, a new workflow will not run even when the repository contains a workflow configured to run when push events occur.
Please create a personal access token in repo setting(write permission accordingly), replace GITHUB_TOKEN.
Token should have admin access rights and write permission on the repository.
What this for.
E.g. you have release branches:
release/R-111
, release/R-112
, release/R-115
and the default master
branch.
You made a hotfix for release/R-111
and pushed it.
This action will be triggered right after the merge. It will check all existing branches. And the branch release/R-112
will be chosen to merge, cause number of them are higher then the number of the branch release/R-111
.
Merges will be perfrmed from release/R-111
, as source branch, to the release/R-112
, as the target branch.
If there were no merge conflicts, a next action will be triggered. It will merge the release/R-112
, as source branch, to the release/R-115
, as the target branch.
E.g a merge-conflict was occurred. In this case the process is stopped and a pull request marked with a special label was created.
release/R-111
was merged only with release/R-112
. When the merge conflict will be resolved and changes pushed in the release/R-115
, another action will be triggered, which won't find a branches with a serial number higher then 115
, therefore it will merge release/R-115
to the master
branch.
So, any updates on a lower-versioned releases will be merged automatically on upper-versioned releases and the main branch.
This action has a special version which handles merging of pull requests. It's placed in the branch named feature/trigger_on-push
, so you can check how to use that.
To use the automerge action you need to create a file root/.git/workflows/any_workflow_name.yml
with content like this:
name: 'Automerge'
on: push
jobs:
merge_to_releases:
runs-on: ubuntu-latest
steps:
- uses: optimaxdev/action-automerge_release@master
name: run_automerge
id: run_automerge
with:
token: ${{ secrets.TOKEN }}
mainBranchName: 'master'
releaseBranchPrfix: 'rel'
releaseBranchTaskPrefix: 'v.'
where:
- mainBranchName - it the "master" branch or another words "default" branch on GitHub repo.
- releaseBranchPrfix - e.g. you pushes releases in branches with names like
rel/v.192
. In this case thereleaseBranchPrfix
parameter must be equals torel
. - releaseBranchTaskPrefix- e.g. you pushes releases in branches with names like
rel/v.192
. In this case thereleaseBranchTaskPrefix
parameter must be equals tov.
. Another example: you pushes releases in branches with names likerelease/REL-00012
. In this case thereleaseBranchTaskPrefix
parameter must be equals toREL-
andreleaseBranchPrfix
=release
. - automergePrLabel - is optional param, which defines which GitHub label name to use for automatically created pull requests when does a merge-conflict with some branch was occurred. All of requests automatically created will be marked up with this label.
You can also specify some other specific params, please see ./actiom.yml
Install the dependencies
$ npm install
Build the typescript and package it for distribution
$ npm run build && npm run package
Run the tests ✔️
$ npm test
PASS ./index.test.js
✓ throws invalid number (3ms)
✓ wait 500 ms (504ms)
✓ test runs (95ms)
...
The action.yml contains defines the inputs and output for your action.
Update the action.yml with your name, description, inputs and outputs for your action.
See the documentation
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
import * as core from '@actions/core';
...
async function run() {
try {
...
}
catch (error) {
core.setFailed(error.message);
}
}
run()
See the toolkit documentation for the various packages.
Actions are run from GitHub repos so we will checkin the packed dist folder.
Then run ncc and push the results:
$ npm run package
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1
Your action is now published! 🚀
See the versioning documentation
The best way to build and push a code is to use the following command:
npm run push
or yarn push
.
Source code will be compiled and pushed to the branch