Closed JoshQuaintance closed 4 years ago
What do you put in secrets.GITHUB_TOKEN
? You need personal access token for cross-repository push.
Ok, I made a personal token and refactor it, but now it gives me this error:
Started: bash /home/runner/work/_actions/ad-m/github-push-action/master/start.sh
Push to branch master
To https://github.com/JoshuaPelealu/catalactics-bot-docs.git
! [rejected] HEAD -> master (fetch first)
error: failed to push some refs to 'https://github.com/JoshuaPelealu/catalactics-bot-docs.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Error: Invalid status code: 1
at ChildProcess.<anonymous> (/home/runner/work/_actions/ad-m/github-push-action/master/start.js:9:19)
at ChildProcess.emit (events.js:210:5)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) {
code: 1
}
Error: Invalid status code: 1
at ChildProcess.<anonymous> (/home/runner/work/_actions/ad-m/github-push-action/master/start.js:9:19)
at ChildProcess.emit (events.js:210:5)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
The workflow is still the same
It looks like you need to push to a branch with no history continuity. If you just want to publish, you can try force: true
.
The push now works, but it pushed everything that is in the first repository... Is there a way to only push 1 file to the other repository. Here's my new workflow:
name: Update Readme
on:
push:
branches: [ master ]
jobs:
update_readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-node@master
with:
node-version: 12
- name: Clean Install Dependencies
run: npm ci
- name: Run Script (update-readme)
run: npm run update-readme
env:
CI: true
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
MONGO_URI: ${{ secrets.MONGO_URI }}
- name: Commit files
run: |
git config --local user.email "45566099+JoshuaPelealu@users.noreply.github.com"
git config --local user.name "Joshua Pelealu"
git add README.md
git status
git commit -m 'Auto Update README' README.md
- name: Push changes
uses: ad-m/github-push-action@master
with:
force: true
repository: 'JoshuaPelealu/catalactics-bot-docs'
github_token: ${{ secrets.ACCESS_TOKEN }}
I figured out a way to do it
All I need is to get the Repository target I want, and add it as a submodule. Then run my script. Then commit the files and push it. Here's my workflow now:
name: Update Readme
on:
push:
branches: [ master ]
jobs:
update_readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-node@master
with:
node-version: 12
- name: Clean Install Dependencies
run: npm ci
- name: Clone documentation repo
run: git submodule add https://github.com/JoshuaPelealu/catalactics-bot-docs
- name: Run Script (update-readme)
run: npm run update-readme catalactics-bot-docs
env:
CI: true
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
MONGO_URI: ${{ secrets.MONGO_URI }}
- name: Commit files
run: |
cd ./catalactics-bot-docs
git config --local user.email "45566099+JoshuaPelealu@users.noreply.github.com"
git config --local user.name "Joshua Pelealu"
git add .
git commit -am 'Auto Update README'
- name: testing
uses: './script.sh'
with:
test_message: "This is just a test"
- name: Push changes
uses: ad-m/github-push-action@master
with:
directory: 'catalactics-bot-docs'
force: true
repository: 'JoshuaPelealu/catalactics-bot-docs'
github_token: ${{ secrets.ACCESS_TOKEN }}
you can just use git clone
instead
on: [push]
jobs:
build:
name: Sphinx Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- name: Clone documentation repo
run: |
git clone https://github.com/zhaoweiguo/demo2
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
cp file1.txt demo2/to
echo hello >> to/artifact2/world.txt
git add .
git commit -m "Add changes" -a
- run: git status
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.ACCESS_TOKEN }}
directory: demo2
repository: 'zhaoweiguo/demo2'
This one is similar to #58 but the user did not show a working solution but instead closing out of the blue. This one also involves the workflow to commit to a different repository.
Anyways, Here's the error generated:
And here is my workflow:
If anyone out there would be kind enough to help me :))...
Thanks in advance!!