Skip to content

Commit a983132

Browse files
authored
Merge pull request #1722 from roboflow/sec/improve-github-workflow-security
Improve GitHub Actions Security
2 parents 64dc2e9 + 06f678e commit a983132

16 files changed

+317
-360
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# These owners will be the default owners for everything in
2+
# the repo. They will be requested for review when someone
3+
# opens a pull request.
4+
* @SkalskiP @LinasKo @onuralpszr

.github/dependabot.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ updates:
44
- package-ecosystem: "github-actions"
55
directory: "/"
66
schedule:
7-
interval: "daily"
7+
interval: "weekly"
88
commit-message:
99
prefix: ⬆️
10+
target-branch: "develop"
1011
# Python
1112
- package-ecosystem: "pip"
1213
directory: "/"
1314
schedule:
14-
interval: "daily"
15+
interval: "weekly"
1516
commit-message:
1617
prefix: ⬆️
18+
target-branch: "develop"

.github/workflows/clear-cache.yml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,42 @@
1-
21
name: Clear cache
32

43
on:
5-
schedule:
6-
- cron: '0 0 1 * *'
7-
workflow_dispatch:
4+
schedule:
5+
- cron: "0 0 1 * *" # Run at midnight on the first day of every month
6+
workflow_dispatch:
87

8+
# Restrict permissions by default
99
permissions:
10-
actions: write
10+
actions: write # Required for cache management
1111

1212
jobs:
1313
clear-cache:
14+
name: Clear cache
1415
runs-on: ubuntu-latest
16+
timeout-minutes: 10
1517
steps:
1618
- name: Clear cache
17-
uses: actions/github-script@v7
19+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
1820
with:
1921
script: |
20-
console.log("About to clear")
22+
console.log("Starting cache cleanup...")
2123
const caches = await github.rest.actions.getActionsCacheList({
2224
owner: context.repo.owner,
2325
repo: context.repo.repo,
2426
})
27+
28+
let deletedCount = 0
2529
for (const cache of caches.data.actions_caches) {
26-
console.log(cache)
27-
github.rest.actions.deleteActionsCacheById({
28-
owner: context.repo.owner,
29-
repo: context.repo.repo,
30-
cache_id: cache.id,
31-
})
30+
console.log(`Deleting cache: ${cache.key} (${cache.size_in_bytes} bytes)`)
31+
try {
32+
await github.rest.actions.deleteActionsCacheById({
33+
owner: context.repo.owner,
34+
repo: context.repo.repo,
35+
cache_id: cache.id,
36+
})
37+
deletedCount++
38+
} catch (error) {
39+
console.error(`Failed to delete cache ${cache.key}: ${error.message}`)
40+
}
3241
}
33-
console.log("Clear completed")
42+
console.log(`Cache cleanup completed. Deleted ${deletedCount} caches.`)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Combine Dependabot PRs
2+
3+
on:
4+
schedule:
5+
- cron: "0 1 * * 3" # Wednesday at 01:00
6+
workflow_dispatch: # allows you to manually trigger the workflow
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
checks: read
12+
13+
jobs:
14+
combine-prs:
15+
name: Combine
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: combine-prs
19+
id: combine-prs
20+
uses: github/combine-prs@2909f404763c3177a456e052bdb7f2e85d3a7cb3 # v5.2.0
21+
with:
22+
labels: combined-pr

.github/workflows/notebook-bot.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

.github/workflows/poetry-test.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ name: 🔧 Poetry Check and Installation Test Workflow
22
on:
33
push:
44
paths:
5-
- 'poetry.lock'
6-
- 'pyproject.toml'
5+
- "poetry.lock"
6+
- "pyproject.toml"
77
pull_request:
88
paths:
9-
- 'poetry.lock'
10-
- 'pyproject.toml'
9+
- "poetry.lock"
10+
- "pyproject.toml"
1111
workflow_dispatch:
1212

1313
jobs:
1414
poetry-tests:
15+
name: Poetry install and check
16+
timeout-minutes: 10
1517
strategy:
1618
fail-fast: false
1719
matrix:
@@ -20,15 +22,15 @@ jobs:
2022
runs-on: ${{ matrix.os }}
2123
steps:
2224
- name: 📥 Checkout the repository
23-
uses: actions/checkout@v4
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2426

2527
- name: 🐍 Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v5
28+
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
2729
with:
2830
python-version: ${{ matrix.python-version }}
2931

30-
- name: 📦 Install the base dependencies
31-
run: python -m pip install --upgrade poetry
32+
- name: 📜 Setup Poetry
33+
uses: abatilo/actions-poetry@e78f54a89cb052fff327414dd9ff010b5d2b4dbd # v3.0.1
3234

3335
- name: 🔍 Check the correctness of the project config
3436
run: poetry check
@@ -38,6 +40,3 @@ jobs:
3840

3941
- name: 🧪 Run the Import test
4042
run: poetry run python -c "import supervision; from supervision import assets; from supervision import metrics; print(supervision.__version__)"
41-
42-
- name: 🧪 Run the pytests
43-
run: poetry run python -m pytest ./test

.github/workflows/publish-dev-docs.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/publish-docs.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Build and Publish Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
workflow_dispatch:
8+
release:
9+
types: [published]
10+
11+
# Ensure only one concurrent deployment
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.ref}}
14+
cancel-in-progress: true
15+
16+
# Restrict permissions by default
17+
permissions:
18+
contents: write # Required for committing to gh-pages
19+
pages: write # Required for deploying to Pages
20+
pull-requests: write # Required for PR comments
21+
22+
jobs:
23+
deploy:
24+
name: Publish Docs
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 10
27+
strategy:
28+
matrix:
29+
python-version: ["3.10"]
30+
steps:
31+
- name: 📥 Checkout the repository
32+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
33+
34+
- name: 🐍 Set up Python ${{ matrix.python-version }}
35+
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
36+
with:
37+
python-version: ${{ matrix.python-version }}
38+
39+
- name: 📜 Setup Poetry
40+
uses: abatilo/actions-poetry@e78f54a89cb052fff327414dd9ff010b5d2b4dbd # v3.0.1
41+
42+
- name: 📦 Install dependencies
43+
run: |
44+
poetry install --with=docs
45+
46+
- name: ⚙️ Configure git for github-actions
47+
run: |
48+
git config --global user.name "github-actions[bot]"
49+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
50+
51+
- name: 🚀 Deploy Development Docs
52+
if: (github.event_name == 'push' && github.ref == 'refs/heads/develop') || github.event_name == 'workflow_dispatch')
53+
run: |
54+
MKDOCS_GIT_COMMITTERS_APIKEY=${{ secrets.GITHUB_TOKEN }} poetry run mike deploy --push develop
55+
56+
- name: 🚀 Deploy Release Docs
57+
if: github.event_name == 'release' && github.event.action == 'published'
58+
run: |
59+
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
60+
MKDOCS_GIT_COMMITTERS_APIKEY=${{ secrets.GITHUB_TOKEN }} poetry run mike deploy --push --update-aliases $latest_tag latest

.github/workflows/publish-release-docs.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)