Example setup

This example shows both setup methods. This is part of a GitHub workflow Action, for example, in your repository: .github/workflow/ci.yml.

Note that only one of the lines, SSH_DEPLOY_KEY or API_TOKEN_GITHUB, are needed according to the chosen setup that is being used.

name: CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    container: pandoc/latex    # "ubuntu" is a more generic container
                               # using "pandoc/latex" because of dependencies
                               # used in the specific "build.sh"
    steps:
      - uses: actions/checkout@v2
      - name: creates output
        run:  sh ./build.sh # some command from your repository that creates
                            # output to "source-directory" ("output" in the example)
      - name: Pushes to another repository
        uses: cpina/github-action-push-to-another-repository@main
        env:
          SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
          API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
        with:
          source-directory: 'output'
          destination-github-username: 'cpina'
          destination-repository-name: 'pandoc-test-output'
          user-email: carles3@pina.cat
          target-branch: main

See the file ci.yml from the origin repository to push to the destination repository.

Besides the variables used in the example (source-destination, destination-github-username, destination-repository-name, user-email and target-branch) there are other available variables:

  1. destination-repository-username: defaults to same as origin

  2. commit-message: defaults to Update from ORIGIN_COMMIT

  3. target-directory: defaults to “/” in the destination repository

  4. github-server: defaults to github.com

  5. create-target-branch-if-needed: defaults to false

See the variables’s documentation in configuration.