Skip to content

Commit cee27f2

Browse files
committed
chore: pin GH actions
1 parent 1edc086 commit cee27f2

3 files changed

Lines changed: 73 additions & 64 deletions

File tree

.github/workflows/check.yaml

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ jobs:
1515

1616
steps:
1717
- name: Checkout repository
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1919
with:
2020
fetch-depth: 0 # Fetch all history
2121
token: ${{ secrets.GITHUB_TOKEN }}
2222

2323
- name: Set up Python
24-
uses: actions/setup-python@v4
24+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
2525
with:
2626
python-version-file: '.python-version'
2727

2828
- name: Install dependencies
2929
run: |
30-
pip install requests
30+
pip install requests==2.32.5
3131
3232
- name: Get OpenAPI version and check for existing PRs
3333
id: version_check
@@ -38,7 +38,7 @@ jobs:
3838
import subprocess
3939
import sys
4040
import os
41-
41+
4242
def get_openapi_version():
4343
"""Get version from OpenAPI spec"""
4444
try:
@@ -49,15 +49,15 @@ jobs:
4949
except Exception as e:
5050
print(f"Error fetching OpenAPI spec: {e}")
5151
return None
52-
52+
5353
def check_existing_prs():
5454
"""Check if there are existing open PRs from the bot"""
5555
try:
5656
result = subprocess.run([
57-
'gh', 'pr', 'list', '--state', 'open',
57+
'gh', 'pr', 'list', '--state', 'open',
5858
'--author', 'app/github-actions', '--json', 'title'
5959
], capture_output=True, text=True, check=True)
60-
60+
6161
prs = json.loads(result.stdout)
6262
for pr in prs:
6363
if 'SDK update' in pr.get('title', '') or 'OpenAPI' in pr.get('title', ''):
@@ -66,19 +66,19 @@ jobs:
6666
except Exception as e:
6767
print(f"Error checking existing PRs: {e}")
6868
return True # Assume PR exists to be safe
69-
69+
7070
# Main logic
7171
print("🔍 Getting OpenAPI version and checking for existing PRs...")
72-
72+
7373
# Get OpenAPI version
7474
openapi_version = get_openapi_version()
75-
75+
7676
if not openapi_version:
7777
print("❌ Could not retrieve OpenAPI version")
7878
sys.exit(1)
79-
79+
8080
print(f"📋 OpenAPI version: {openapi_version}")
81-
81+
8282
# Check for existing PRs
8383
if check_existing_prs():
8484
print("📋 Existing PR found, skipping SDK generation")
@@ -89,15 +89,15 @@ jobs:
8989
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
9090
f.write(f"should_generate=true\n")
9191
f.write(f"openapi_version={openapi_version}\n")
92-
92+
9393
print("✅ Check completed")
9494
EOF
9595
env:
9696
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9797

9898
- name: Generate Python SDK
9999
if: steps.version_check.outputs.should_generate == 'true'
100-
uses: openapi-generators/openapitools-generator-action@v1
100+
uses: openapi-generators/openapitools-generator-action@b729d184e6b3459572c37c0e37f88a832e69b552 # v1
101101
with:
102102
generator: python
103103
generator-tag: 'v7.17.0'
@@ -110,6 +110,8 @@ jobs:
110110
- name: Check for changes
111111
if: steps.version_check.outputs.should_generate == 'true'
112112
id: check_changes
113+
env:
114+
OPENAPI_VERSION: ${{ steps.version_check.outputs.openapi_version }}
113115
run: |
114116
# Move generated files to the correct locations and clean up
115117
rm -Rf docs && mv python-client/docs .
@@ -119,20 +121,20 @@ jobs:
119121
rm -Rf python-client
120122
121123
# Store the SDK version
122-
echo ${{ steps.version_check.outputs.openapi_version }} > .sdk-version
124+
echo "$OPENAPI_VERSION" > .sdk-version
123125
124126
# Configure git
125127
git config user.name "github-actions[bot]"
126128
git config user.email "github-actions[bot]@users.noreply.github.com"
127-
129+
128130
# Check if there are any changes
129131
if git diff --quiet && git diff --cached --quiet; then
130132
echo "No changes detected in generated SDK"
131133
echo "has_changes=false" >> $GITHUB_OUTPUT
132134
else
133135
echo "Changes detected in generated SDK"
134136
echo "has_changes=true" >> $GITHUB_OUTPUT
135-
137+
136138
# Show what changed
137139
echo "Files changed:"
138140
git diff --name-only
@@ -142,43 +144,47 @@ jobs:
142144
fi
143145
144146
- name: Generate a token
147+
if: steps.version_check.outputs.should_generate == 'true' && steps.check_changes.outputs.has_changes == 'true'
145148
id: generate-token
146-
uses: actions/create-github-app-token@v2
149+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
147150
with:
148-
app-id: ${{ vars.REVENG_APP_ID }}
151+
app-id: ${{ secrets.REVENG_APP_ID }}
149152
private-key: ${{ secrets.REVENG_APP_PRIVATE_KEY }}
150153
owner: ${{ github.repository_owner }}
151154
repositories: |
152155
sdk-python
153156
154157
- name: Create Pull Request
155158
if: steps.version_check.outputs.should_generate == 'true' && steps.check_changes.outputs.has_changes == 'true'
159+
env:
160+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
161+
OPENAPI_VERSION: ${{ steps.version_check.outputs.openapi_version }}
156162
run: |
157163
# Create a new branch
158-
BRANCH_NAME="sdk-update-${{ steps.version_check.outputs.openapi_version }}"
164+
BRANCH_NAME="sdk-update-${OPENAPI_VERSION}"
159165
git checkout -b "$BRANCH_NAME"
160-
166+
161167
# Stage all changes
162168
git add .
163-
169+
164170
# Commit changes
165-
git commit -m "Update SDK to version ${{ steps.version_check.outputs.openapi_version }}
171+
git commit -m "Update SDK to version ${OPENAPI_VERSION}
166172
167-
- Generated from OpenAPI spec version ${{ steps.version_check.outputs.openapi_version }}
173+
- Generated from OpenAPI spec version ${OPENAPI_VERSION}
168174
- Auto-generated by GitHub Actions"
169-
175+
170176
# Push the branch
171177
git push -f origin "$BRANCH_NAME"
172-
178+
173179
# Create PR using GitHub CLI
174180
gh pr create \
175-
--title "🤖 Update SDK to version ${{ steps.version_check.outputs.openapi_version }}" \
181+
--title "🤖 Update SDK to version ${OPENAPI_VERSION}" \
176182
--body "## 🔄 Automated SDK Update
177183
178184
This PR was automatically generated to update the Python SDK to match the latest OpenAPI specification.
179185
180186
### 📊 Version Information
181-
- **OpenAPI Spec Version**: \`${{ steps.version_check.outputs.openapi_version }}\`
187+
- **OpenAPI Spec Version**: \`${OPENAPI_VERSION}\`
182188
183189
### 🔧 Changes
184190
- Generated fresh SDK from [OpenAPI specification](https://api.reveng.ai/openapi.json)
@@ -194,8 +200,6 @@ jobs:
194200
🤖 *This PR was created automatically by GitHub Actions*" \
195201
--head "$BRANCH_NAME" \
196202
--base main
197-
203+
198204
echo "✅ Pull request created successfully"
199-
echo "::notice title=PR Created::Created PR for SDK update to version ${{ steps.version_check.outputs.openapi_version }}"
200-
env:
201-
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
205+
echo "::notice title=PR Created::Created PR for SDK update to version ${OPENAPI_VERSION}"

.github/workflows/publish.yaml

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ jobs:
1515

1616
steps:
1717
- name: Checkout repository
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1919

2020
- name: Generate a token
2121
id: generate-token
22-
uses: actions/create-github-app-token@v2
22+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
2323
with:
24-
app-id: ${{ vars.REVENG_APP_ID }}
24+
app-id: ${{ secrets.REVENG_APP_ID }}
2525
private-key: ${{ secrets.REVENG_APP_PRIVATE_KEY }}
2626

2727
- name: Read version from file
@@ -31,65 +31,65 @@ jobs:
3131
echo "Error: .sdk-version file not found"
3232
exit 1
3333
fi
34-
34+
3535
VERSION=$(cat .sdk-version | tr -d '\n\r' | xargs)
36-
36+
3737
if [ -z "$VERSION" ]; then
3838
echo "Error: .sdk-version file is empty"
3939
exit 1
4040
fi
41-
41+
4242
echo "Found version: $VERSION"
4343
echo "version=$VERSION" >> $GITHUB_OUTPUT
4444
4545
- name: Check if tag already exists
4646
id: check-tag
47+
env:
48+
SDK_VERSION: ${{ steps.version.outputs.version }}
4749
run: |
48-
if git ls-remote --tags origin | grep -q "refs/tags/${{ steps.version.outputs.version }}$"; then
49-
echo "Tag ${{ steps.version.outputs.version }} already exists"
50+
if git ls-remote --tags origin | grep -q "refs/tags/${SDK_VERSION}$"; then
51+
echo "Tag ${SDK_VERSION} already exists"
5052
echo "tag_exists=true" >> $GITHUB_OUTPUT
5153
else
52-
echo "Tag ${{ steps.version.outputs.version }} does not exist"
54+
echo "Tag ${SDK_VERSION} does not exist"
5355
echo "tag_exists=false" >> $GITHUB_OUTPUT
5456
fi
5557
5658
- name: Create and push tag
5759
if: steps.check-tag.outputs.tag_exists == 'false'
5860
env:
5961
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
62+
SDK_VERSION: ${{ steps.version.outputs.version }}
6063
run: |
6164
git config --global user.name "reveng-github[bot]"
6265
git config --global user.email "reveng-github[bot]@users.noreply.github.com"
63-
66+
6467
# Configure git to use the token for authentication
65-
git remote set-url origin https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com/${{ github.repository }}.git
66-
67-
TAG_NAME="${{ steps.version.outputs.version }}"
68-
69-
git tag "$TAG_NAME"
70-
git push origin "$TAG_NAME"
71-
72-
echo "Created and pushed tag: $TAG_NAME"
68+
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
69+
70+
git tag "$SDK_VERSION"
71+
git push origin "$SDK_VERSION"
72+
73+
echo "Created and pushed tag: $SDK_VERSION"
7374
7475
- name: Create GitHub release
7576
if: steps.check-tag.outputs.tag_exists == 'false'
7677
env:
7778
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
79+
SDK_VERSION: ${{ steps.version.outputs.version }}
7880
run: |
79-
TAG_NAME="${{ steps.version.outputs.version }}"
80-
81-
gh release create "$TAG_NAME" \
82-
--title "$TAG_NAME" \
83-
--notes "$TAG_NAME" \
81+
gh release create "$SDK_VERSION" \
82+
--title "$SDK_VERSION" \
83+
--notes "$SDK_VERSION" \
8484
--verify-tag
8585
8686
- name: Set up Python
87-
uses: actions/setup-python@v4
87+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
8888
with:
8989
python-version-file: '.python-version'
9090

9191
- name: Install uv
92-
uses: astral-sh/setup-uv@v5
92+
uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
9393

9494
- name: Build and publish package to PyPI
9595
if: steps.check-tag.outputs.tag_exists == 'false'
@@ -99,12 +99,13 @@ jobs:
9999
100100
- name: Notify the releases channel about the release
101101
if: steps.check-tag.outputs.tag_exists == 'false'
102-
uses: slackapi/slack-github-action@v2.0.0
102+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
103103
env:
104-
REPO_URL: "${{github.server_url}}/${{github.repository}}"
105-
RELEASE_URL: "${{github.server_url}}/${{github.repository}}/releases/tag/${{ steps.version.outputs.version }}"
104+
REPO_URL: "${{ github.server_url }}/${{ github.repository }}"
105+
RELEASE_URL: "${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.version.outputs.version }}"
106+
SDK_VERSION: ${{ steps.version.outputs.version }}
106107
with:
107108
webhook: ${{ secrets.RELEASES_SLACK_WEBHOOK }}
108109
webhook-type: incoming-webhook
109110
payload: |
110-
text: "<${{ env.RELEASE_URL }}|${{ steps.version.outputs.version }}> has been released for <${{ env.REPO_URL }}|${{ github.repository }}>"
111+
text: "<${{ env.RELEASE_URL }}|${{ env.SDK_VERSION }}> has been released for <${{ env.REPO_URL }}|${{ github.repository }}>"

.github/workflows/test.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,25 @@ on:
66
jobs:
77
test:
88
runs-on: ubuntu-latest
9+
10+
permissions:
11+
contents: read
12+
913
strategy:
1014
matrix:
1115
python-version: ['3.10', '3.11', '3.12', '3.13']
1216

1317
steps:
1418
- name: Checkout repository
15-
uses: actions/checkout@v4
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1620

1721
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v4
22+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
1923
with:
2024
python-version: ${{ matrix.python-version }}
2125

2226
- name: Install uv
23-
uses: astral-sh/setup-uv@v3
27+
uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
2428

2529
- name: Install dependencies
2630
run: |

0 commit comments

Comments
 (0)