-
Notifications
You must be signed in to change notification settings - Fork 35
158 lines (139 loc) · 5.45 KB
/
update-deps.yml
File metadata and controls
158 lines (139 loc) · 5.45 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Update Dependencies and API
on:
workflow_dispatch:
inputs:
version_bump:
description: 'Version bump type'
required: true
type: choice
options:
- patch
- minor
- major
default: patch
update_dependencies:
description: 'Update dependencies'
required: true
type: boolean
default: true
generate_api:
description: 'Generate API'
required: true
type: boolean
default: true
jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: read
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Install dependencies
run: npm ci
- name: Update dependencies
if: ${{ inputs.update_dependencies }}
run: |
echo "🔄 Updating dependencies..."
# Update all dependencies to latest versions
npm update
# Specifically update daily-co to latest
npm install @daily-co/daily-js@latest --save
echo "✅ Dependencies updated"
- name: Generate API
if: ${{ inputs.generate_api }}
run: |
echo "🔄 Generating API..."
chmod +x ./generate-api.sh
npm run generate-api
echo "✅ API generated"
- name: Bump version
id: version
run: |
echo "🔄 Bumping version (${{ inputs.version_bump }})..."
NEW_VERSION=$(npm version ${{ inputs.version_bump }} --no-git-tag-version)
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "✅ Version bumped to $NEW_VERSION"
- name: Build and test
run: |
echo "🔄 Building and testing..."
npm run build
npm test || echo "⚠️ Tests failed but continuing..."
echo "✅ Build completed"
- name: Test example project
run: npm run test:example
- name: Check for changes
id: changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "HAS_CHANGES=true" >> $GITHUB_OUTPUT
echo "✅ Changes detected"
else
echo "HAS_CHANGES=false" >> $GITHUB_OUTPUT
echo "ℹ️ No changes detected"
fi
- name: Create Pull Request
if: steps.changes.outputs.HAS_CHANGES == 'true'
id: create_pr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: |
chore: update dependencies and bump version to ${{ steps.version.outputs.NEW_VERSION }}
- Update dependencies to latest versions
- Regenerate API definitions
- Bump version to ${{ steps.version.outputs.NEW_VERSION }}
title: "chore: update dependencies and bump version to ${{ steps.version.outputs.NEW_VERSION }}"
body: |
## 🔄 Automated Update
This PR contains automated updates:
### Changes Made
- ✅ **Dependencies**: ${{ inputs.update_dependencies && 'Updated to latest versions' || 'Skipped' }}
- ✅ **API Generation**: ${{ inputs.generate_api && 'Regenerated API definitions' || 'Skipped' }}
- ✅ **Version Bump**: Bumped version to `${{ steps.version.outputs.NEW_VERSION }}` (${{ inputs.version_bump }})
### Files Changed
- `package.json` - Version bumped
- `package-lock.json` - Dependencies updated
- `api.ts` - API definitions regenerated (if applicable)
### Next Steps
1. Review the changes
2. Merge this PR
3. Create a GitHub release with tag `${{ steps.version.outputs.NEW_VERSION }}`
4. The release workflow will automatically publish to npm
---
*This PR was created automatically by the Update Dependencies workflow.*
branch: update-deps-${{ steps.version.outputs.NEW_VERSION }}
delete-branch: true
draft: false
- name: Summary
run: |
if [ "${{ steps.changes.outputs.HAS_CHANGES }}" == "true" ]; then
if [ "${{ steps.create_pr.outputs.pull-request-number }}" != "" ]; then
echo "✅ Pull request created successfully!"
echo "🔗 PR URL: ${{ steps.create_pr.outputs.pull-request-url }}"
echo "📋 Summary:"
echo " - PR Number: #${{ steps.create_pr.outputs.pull-request-number }}"
echo " - Version: ${{ steps.version.outputs.NEW_VERSION }}"
echo " - Dependencies updated: ${{ inputs.update_dependencies }}"
echo " - API generated: ${{ inputs.generate_api }}"
else
echo "❌ Failed to create pull request!"
echo "Please check the workflow logs for more details."
exit 1
fi
else
echo "ℹ️ No changes were made, so no PR was created."
fi