Skip to content

Commit 12305d5

Browse files
committed
Add
1 parent 0df0e6f commit 12305d5

File tree

4 files changed

+93
-40
lines changed

4 files changed

+93
-40
lines changed

.github/scripts/remove-packages.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const { Octokit } = require("@octokit/rest");
2-
31
const removePackageVersions = async (imageUrl, imageVersions) => {
2+
const { Octokit } = await import("@octokit/rest");
3+
44
const octokit = new Octokit({
55
auth: process.env.GITHUB_TOKEN,
66
});
@@ -11,7 +11,7 @@ const removePackageVersions = async (imageUrl, imageVersions) => {
1111
await octokit.rest.packages.deletePackageVersionForOrg({
1212
package_type: "container",
1313
package_name: imageName,
14-
username: imageOwner,
14+
org: imageOwner,
1515
package_version_id: imageId,
1616
});
1717
}
@@ -26,7 +26,7 @@ const loadOutdatedVersionIds = async (octokit, imageOwner, imageName, versions)
2626
const response = await octokit.rest.packages.getAllPackageVersionsForPackageOwnedByOrg({
2727
package_type: "container",
2828
package_name: imageName,
29-
username: imageOwner,
29+
org: imageOwner,
3030
page,
3131
});
3232
if (response.data.length === 0) {

.github/scripts/remove.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const removePackageVersions = async (imageUrl) => {
2+
const { Octokit } = await import("@octokit/rest");
3+
4+
const octokit = new Octokit({
5+
auth: process.env.GITHUB_TOKEN,
6+
});
7+
8+
const [_imageHost, imageOwner, imageName] = imageUrl.split("/");
9+
await octokit.rest.packages.deletePackageForOrg({
10+
package_type: "container",
11+
package_name: imageName,
12+
org: imageOwner,
13+
});
14+
};
15+
16+
module.exports = {
17+
removePackageVersions,
18+
};

.github/workflows/code-quality.yml

Lines changed: 70 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,41 +34,11 @@ jobs:
3434
uses: actions/dependency-review-action@v4
3535

3636

37-
check-changelog:
38-
name: "Check CHANGELOG"
39-
runs-on: ubuntu-latest
40-
steps:
41-
- name: Checkout code
42-
uses: actions/checkout@v4
43-
with:
44-
# Fetch full history for comparison
45-
fetch-depth: 0
46-
- name: Determine if branch is a feature branch
47-
id: check_feature_branch
48-
run: |
49-
if [[ "${{ github.head_ref || github.ref_name }} " =~ ^feature/* ]]; then
50-
echo "is_feature=true" >> $GITHUB_ENV
51-
else
52-
echo "is_feature=false" >> $GITHUB_ENV
53-
fi
54-
- name: Check if CHANGELOG.md has changed
55-
if: env.is_feature == 'true'
56-
run: |
57-
# Compare the CHANGELOG.md file in the current branch with the `develop` branch
58-
if git diff --name-only origin/develop...HEAD | grep -q '^CHANGELOG.md$'; then
59-
echo "CHANGELOG.md has been updated."
60-
else
61-
echo "CHANGELOG.md has not been updated."
62-
exit 1
63-
fi
64-
65-
6637
install-ui:
6738
name: "Install UI"
6839
runs-on: ubuntu-latest
6940
needs:
7041
- dependency-review
71-
- check-changelog
7242
steps:
7343
- name: Checkout repository
7444
uses: actions/checkout@v4
@@ -165,7 +135,6 @@ jobs:
165135
runs-on: ubuntu-latest
166136
needs:
167137
- dependency-review
168-
- check-changelog
169138
steps:
170139
- name: Checkout repository
171140
uses: actions/checkout@v4
@@ -210,9 +179,6 @@ jobs:
210179
rm -r tests/
211180
echo "fn main() {}" > src/main.rs
212181
cargo build --all-targets --locked --quiet
213-
214-
rustup component add rustfmt
215-
rustup component add clippy
216182
217183
218184
check-api:
@@ -264,6 +230,7 @@ jobs:
264230
toolchain: ${{ env.RUST_VERSION }}
265231
profile: minimal
266232
override: true
233+
components: clippy, rustfmt
267234
- name: Restore cargo registry
268235
uses: actions/cache/restore@v4
269236
with:
@@ -286,7 +253,7 @@ jobs:
286253
- name: Run clippy
287254
run: |
288255
cd api
289-
cargo clippy --frozen
256+
cargo clippy --frozen --quiet
290257
291258
292259
test-api:
@@ -346,3 +313,71 @@ jobs:
346313
run: |
347314
kill $(cat api.pid)
348315
docker compose down
316+
317+
318+
check-changelog:
319+
name: "Check CHANGELOG"
320+
runs-on: ubuntu-latest
321+
steps:
322+
- name: Checkout code
323+
uses: actions/checkout@v4
324+
with:
325+
# Fetch full history for comparison
326+
fetch-depth: 0
327+
- name: Determine if branch is a feature branch
328+
id: check_feature_branch
329+
run: |
330+
if [[ "${{ github.head_ref || github.ref_name }} " =~ ^feature/* ]]; then
331+
echo "is_feature=true" >> $GITHUB_ENV
332+
else
333+
echo "is_feature=false" >> $GITHUB_ENV
334+
fi
335+
- name: Check if CHANGELOG.md has changed
336+
if: env.is_feature == 'true'
337+
continue-on-error: true
338+
run: |
339+
# Compare the CHANGELOG.md file in the current branch with the `develop` branch
340+
if git diff --name-only origin/develop...HEAD | grep -q '^CHANGELOG.md$'; then
341+
echo "CHANGELOG.md has been updated."
342+
else
343+
echo "::warning file=CHANGELOG.md::CHANGELOG.md has not been updated."
344+
exit 1
345+
exit 1
346+
fi
347+
348+
349+
prefer-single-commit:
350+
name: "Prefer Single Commit"
351+
runs-on: ubuntu-latest
352+
steps:
353+
- name: Checkout code
354+
uses: actions/checkout@v4
355+
with:
356+
# Fetch full history for comparison
357+
fetch-depth: 0
358+
- name: Count commits
359+
id: count_commits
360+
run: |
361+
commit_count=$(git rev-list --count HEAD ^origin/${{ github.event.pull_request.base.ref }})
362+
echo "commit_count=$commit_count" >> $GITHUB_ENV
363+
- name: Fail if more than one commit
364+
if: env.commit_count > 1
365+
run: |
366+
echo "::error title=Please Squash your PR::Pull request contains more than one commit ($commit_count commits). Please squash your commits."
367+
368+
cleanup:
369+
runs-on: ubuntu-latest
370+
steps:
371+
- name: Checkout code
372+
uses: actions/checkout@v4
373+
- name: Setup node
374+
run: |
375+
npm install @octokit/rest
376+
- name: Remove
377+
env:
378+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
379+
run: |
380+
curl -X DELETE \
381+
-H "Authorization: token $GITHUB_TOKEN" \
382+
-H "Accept: application/vnd.github.v3+json" \
383+
https://api.github.com/orgs/swisstopo/packages/container/swissgeol-viewer-app-api

ui/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM node:22-alpine as build
33
WORKDIR /app
44
COPY . .
55

6-
RUN npm install --no-scripts
6+
RUN npm install --ignore-scripts
77
RUN npm run build --omit=dev
88

99

0 commit comments

Comments
 (0)