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

feat(flows.yaml): [nan-1761] add github app push #3

Merged
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
84 changes: 84 additions & 0 deletions .github/workflows/push-flows-to-nango-repo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Push flows to Nango repo

on:
push:
branches:
- main

concurrency:
group: push-flows-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
push_to_nango_repo:
runs-on: ubuntu-latest
steps:
- name: Checkout the current repository
uses: actions/checkout@v3

- name: Log current branch and repository
run: |
echo "Current branch: ${{ github.ref }}"
echo "Repository: ${{ github.repository }}"

- name: Check for changes in flows.yaml
id: changes
uses: tj-actions/changed-files@v41
with:
files: 'flows.yaml'

- name: Debug - Log if flows.yaml has changed
run: |
if [ "${{ steps.changes.outputs.any_changed }}" == "true" ]; then
echo "flows.yaml has changed."
else
echo "No changes detected in flows.yaml."
fi

- name: Generate GitHub App Token
if: steps.changes.outputs.any_changed == 'true'
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.GH_APP_PUSHER_ID }}
private_key: ${{ secrets.GH_APP_PUSHER_PRIVATE_KEY }}

- name: Debug - Log token generation status
if: steps.changes.outputs.any_changed == 'true'
run: |
echo "GitHub App token generated."

- name: Clone the target repository and copy the flows.yaml file
if: steps.changes.outputs.any_changed == 'true'
run: |
echo "Cloning the target repository..."
git clone https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/NangoHQ/nango.git
echo "Repository cloned."
echo "Copying flows.yaml into the nango repository."
cp flows.yaml nango/packages/shared/flows.yaml
echo "flows.yaml file copied."

- name: Debug - Log nango directory contents
if: steps.changes.outputs.any_changed == 'true'
run: |
echo "Contents of nango directory after copying flows.yaml:"
ls nango/

- name: Make changes and commit
if: steps.changes.outputs.any_changed == 'true'
working-directory: nango
run: |
echo "Configuring Git and committing changes..."
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions Bot"
git add packages/shared/flows.yaml
git commit -m "Automated commit updating flows.yaml from the integration-templates repo"
echo "Changes committed."

- name: Push changes to target repo
if: steps.changes.outputs.any_changed == 'true'
working-directory: nango
run: |
echo "Pushing changes to target repository..."
git push origin master
echo "Changes pushed successfully."
Loading