-
Notifications
You must be signed in to change notification settings - Fork 1
118 lines (99 loc) · 4.83 KB
/
push-flows-to-nango-repo.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Push flows and docs to Nango repo
on:
push:
branches:
- main
concurrency:
group: push-flows-${{ 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."
echo "Updating documentation snippets"
cd nango
npm ci
npm run docs:generate
- name: Debug - status on nango after copying
if: steps.changes.outputs.any_changed == 'true'
working-directory: nango
run: |
echo "Status of nango directory after copying flows.yaml:"
git status
- name: Get Commit Details
if: steps.changes.outputs.any_changed == 'true'
id: commit_details
run: |
# Get the latest commit details
COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an")
COMMIT_URL="https://github.com/${{ github.repository }}/commit/${{ github.sha }}"
echo "Commit message: $COMMIT_MESSAGE"
echo "Commit author: $COMMIT_AUTHOR"
echo "Commit URL: $COMMIT_URL"
# Write them to the GITHUB_OUTPUT environment file
echo "commit_message=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
echo "commit_author=$COMMIT_AUTHOR" >> $GITHUB_OUTPUT
echo "commit_url=$COMMIT_URL" >> $GITHUB_OUTPUT
- 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"
# Add the changes
git add packages/shared/flows.yaml
git add docs-v2/snippets/
# Get commit details from the previous step
COMMIT_MESSAGE="${{ steps.commit_details.outputs.commit_message }}"
COMMIT_AUTHOR="${{ steps.commit_details.outputs.commit_author }}"
COMMIT_URL="${{ steps.commit_details.outputs.commit_url }}"
# Commit with a message that includes commit details
git commit -m "chore(integration-templates): Automated commit updating flows.yaml based on changes in $COMMIT_URL by $COMMIT_AUTHOR. Commit message: $COMMIT_MESSAGE"
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."