According to this troubleshooting in Github page:
https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#example
I prepared separate workflow files with same name
and job name
:
/.github/workflows/feature-branches-build.yml
/.github/workflows/i18n-branch-build.yml
feature-branches-build.yml
:
name: Feature branch CI
on:
push:
branches:
- 'feature/**'
jobs:
feature-branch:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# caching node_modules
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: |
npm ci
- name: Code style
run: |
npm run prettier
- name: Lint
run: |
npm run lint:all
- name: Test
run: |
npm run test:all
- name: Build
run: |
npm run build
i18n-branch-build.yml
:
name: Feature branch CI
on:
push:
branches:
- 'lingohub*'
jobs:
feature-branch:
runs-on: ubuntu-latest
outputs:
reformat-commit-sha: ${{ steps.push-changes.outputs.reformat-commit-sha }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
ref: ${{ github.head_ref }}
- uses: actions/setup-node@v3
with:
node-version: '14'
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- run: npm install -g prettier
- name: Formatting files
run: npm run prettier:i18n
- name: Check for modified files
id: git-check
run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
- name: Push changes
id: push-changes
if: steps.git-check.outputs.modified == 'true'
run: |
git config user.name 'Github Actions'
git config user.email 'github-actions@users.noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git add .
git commit --amend --no-edit --allow-empty
git push --force --no-verify
echo "::set-output name=reformat-commit-sha::$(git rev-parse HEAD)"
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# caching node_modules
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: |
npm ci
- name: Code style
run: |
npm run prettier
- name: Lint
run: |
npm run lint:all
- name: Test
run: |
npm run test:all
- name: Build
run: |
npm run build
The issue:
- Push branch
lingohub-....
with incorrect formatting - Workflow
i18n-branch-build
starts. - The required check
feature-branch
spinning - When workflow does the
push --force
then the connection between running workflow and the pull request checks - is missing.
After pushing new branch. Everything seems to be ok.
But when workflow completes the push --force
:
And the check is out of sync. Even if whole workflow ends with success:
I have no idea why it happens. Any ideas?