'GitHub Workflow - auto push to git repo after pull_request

I host my git-repo on GitHub.com. Several developers contribute code to either the develop- or feature branch respectively. Once all the tests have passed, the changes are merged into master.

Now, once such a pull-request/merge has been done, the master brach shall be pushed automatically to another GitHub-Repo (where another team picks it up). This is when "Workflows" come into play. So I created this yaml file to trigger a "git push" after a successfull pull-requrest:

name: push master to official repository
on:
  pull_request:
    types: [closed]
jobs:
  gitHubPush:
    runs-on: ubuntu-latest
    steps:
     - run: "git push https://github.com/OFFICIAL/MyProject master"

But this doesn't work. I get:

fatal: not a git repository (or any of the parent directories): .git Error: Process completed with exit code 128.

The GitHub Account is registered as "Contributor" on OFFICIAL.

Can you help me out ?



Solution 1:[1]

You have to checkout your repository first:

- name: Checkout
  uses: actions/checkout@v2

More information about checkout options to find the best fitting your needs here: https://github.com/actions/checkout/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Grzegorz Krukowski