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

Add push to another repository workflow #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions github-actions/push-to-another-repository/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Push to another repository

## The problem
Sometimes we need push code from `Repository A`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Sometimes we need push code from `Repository A`
Sometimes we need to push the code from `Repository A`

action to `Repository B` codebase, for eg. when we are implementing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
action to `Repository B` codebase, for eg. when we are implementing
action to the `Repository B` codebase, for e.g., when we are implementing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be e.g. or for example, "for" is already included in e.g. :D

GitOps(for the deployment repo) or when we need separate repo for build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GitOps(for the deployment repo) or when we need separate repo for build
GitOps(for the deployment repo) or when we need separate repo for the build

process for eg. with Design Tokens.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
process for eg. with Design Tokens.
process for e.g. with Design Tokens.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here "e.g. / for example"


## Solution
We can leverage GitHub deploy keys(https://docs.github.com/en/developers/overview/managing-deploy-keys), heres how:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We can leverage GitHub deploy keys(https://docs.github.com/en/developers/overview/managing-deploy-keys), heres how:
We can leverage GitHub deploy keys ([managing deploy keys](https://docs.github.com/en/developers/overview/managing-deploy-keys)), here is how:

1) Follow the steps in the official guide.
2) In step 4 add key to our destination(`Repository B`) repo.
3) In step 7 check `Allow write access`.
4) Go to source repo(`Repository A`).
5) Go to `Settings` > `Secrets` > `Actions`.
6) Click `New repository secret`.
7) Add name for eg. `DEPLOY_SSH_KEY` - remember it must match variable name used in workflow.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
7) Add name for eg. `DEPLOY_SSH_KEY` - remember it must match variable name used in workflow.
7) Add a name for e.g. `DEPLOY_SSH_KEY` - remember it must match the variable name used in the workflow.

8) As content paste your private key `.pem`.
9) Add push step form `push-to-another-repo.yml` file to your workflow.
23 changes: 23 additions & 0 deletions github-actions/push-to-another-repository/push-to-another-repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Deploy
on:
push:
branches:
- master
jobs:
deploy-to-separate-repo:
name: Commit and push
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
repository: 'Selleo/dev-templates' # Put your repo here
ref: 'master'
ssh-key: ${{ secrets.DEPLOY_SSH_KEY }} # Ensure that it matches your secret
- name: Push
run: |-
git config user.name github-actions
git config user.email [email protected]
git add your_changes.txt # Add files that you want to push
git commit -m "Deploy" # Customize your commit message
git push