简体   繁体   中英

Github post push hook

is it possible on Github to have a post hook on branch DEV that automatically pushes changes to QA and STAGING?

In order to comply to some restriction we need DEV, QA, and STAGING branches to be the same so when a push happens on dev, changes are also pushed to QA and STAGING.

This is possible using GitHub Actions. You'd set up an action like so:

name: ci
on:
  push:
    branches:
      - dev

jobs:
  push:
    name: Update QA and Staging Branches
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - run: git push origin dev:qa dev:staging

Note that this assumes your dev , qa , and staging branches are all identical. That is a slightly silly way of going about things, and you'd probably be better off having only one branch for all three.

If your branches aren't identical, then you'll need to perform a merge instead from dev into qa and then dev into staging , but be aware that unless you've checked that the branches are mergeable in CI, it's possible they won't be, and you'll need to gracefully handle that case. The commands you'd want to use would look more like this, and you'd need to update the actions/checkout action to pull in full history:

$ git checkout qa
$ git merge origin/dev
$ git checkout staging
$ git merge origin/dev
$ git push origin qa staging

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM