Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync fails with "Set the GITHUB_TOKEN environment variable." #107

Closed
ajshastri opened this issue Feb 7, 2023 · 2 comments
Closed

Sync fails with "Set the GITHUB_TOKEN environment variable." #107

ajshastri opened this issue Feb 7, 2023 · 2 comments

Comments

@ajshastri
Copy link

Hello,

I used the following repo-sync.yml

# File: .github/workflows/repo-sync.yml
name: Repo Sync

on:
  schedule:
  - cron:  "*/5 * * * *"
  workflow_dispatch:

jobs:
  repo-sync:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        persist-credentials: false
    - name: repo-sync
      uses: repo-sync/github-sync@v2
      with:
        source_repo: ${{ secrets.SOURCE_REPO }}
        source_branch: ${{ secrets.INTERMEDIATE_BRANCH }}
        destination_branch: "*"
        github_token: ${{ secrets.PAT }}
        sync_tags: "true"

My actions fail with


Run repo-sync/github-sync@v[2](https://github.com/ajshastri/gnumake/actions/runs/4110292610/jobs/7092964910#step:4:2)
  with:
    destination_branch: *
    sync_tags: true
/usr/bin/docker run --name ghcrioreposyncgithubsyncv2[3](https://github.com/ajshastri/gnumake/actions/runs/4110292610/jobs/7092964910#step:4:3)0_97009a --label [4](https://github.com/ajshastri/gnumake/actions/runs/4110292610/jobs/7092964910#step:4:4)98[5](https://github.com/ajshastri/gnumake/actions/runs/4110292610/jobs/7092964910#step:4:6)9c --workdir /github/workspace --rm -e "INPUT_SOURCE_REPO" -e "INPUT_SOURCE_BRANCH" -e "INPUT_DESTINATION_BRANCH" -e "INPUT_GITHUB_TOKEN" -e "INPUT_SYNC_TAGS" -e "GITHUB_TOKEN" -e "SYNC_TAGS" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/gnumake/gnumake":"/github/workspace" ghcr.io/repo-sync/github-sync:v2.3.0  "" ":*"
Set the GITHUB_TOKEN environment variable.

I've set the secrets variables for SOURCE_REPO, INTERMEDIATE_BRANCH and PAT but it seems to want the GITHUB_TOKEN which github will not let me.

@WillyRL
Copy link

WillyRL commented Apr 15, 2024

Hi,
The GITHUB_TOKEN is mandatory so the action can make changes to the destination repository ( The one that you run the action on )

    - name: repo-sync
      env:
        SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
       ...

Make sure to give the Github Action the right permission on the repository by following steps below :

  • Go to your repository settings on GitHub.
  • Navigate to "Actions" > "General".
  • Under "Workflow permissions", select "Read and write permissions".

@heiskr
Copy link
Contributor

heiskr commented May 20, 2024

Thank you @WillyRL, that is the correct answer :)

@heiskr heiskr closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants