Skip to content

Commit cfd17ae

Browse files
authored
Merge pull request #1475 from netomi/fix-ci-workflow
Improve CI workflow
2 parents f9ffec5 + fb9505b commit cfd17ae

File tree

5 files changed

+251
-125
lines changed

5 files changed

+251
-125
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
groups:
8+
github-actions:
9+
patterns:
10+
- "*"

.github/workflows/main.yml

Lines changed: 99 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,61 +9,133 @@ on:
99
- master
1010

1111
env:
12-
SERVER_TAG: ghcr.io/eclipse/openvsx-server
13-
WEBUI_TAG: ghcr.io/eclipse/openvsx-webui
12+
REGISTRY: ghcr.io
13+
SERVER_IMAGE: openvsx-server
14+
WEBUI_IMAGE: openvsx-webui
1415

1516
jobs:
16-
build:
17+
build-and-push-cli-and-webui:
1718
permissions:
18-
contents: none
19+
contents: read
20+
packages: write
21+
id-token: write
1922
runs-on: ubuntu-latest
2023
steps:
24+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
25+
with:
26+
persist-credentials: false
27+
2128
- name: Set up Node.js
22-
uses: actions/setup-node@v4
29+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
2330
with:
2431
node-version: 18.x
25-
- name: Set up JDK
26-
uses: actions/setup-java@v4
27-
with:
28-
distribution: 'temurin'
29-
java-version: 25
32+
3033
- name: Install Yarn
3134
run: |
3235
corepack enable
3336
corepack prepare yarn@stable --activate
34-
- uses: actions/checkout@v4
35-
- name: Set Image Version
36-
run: echo "IMAGE_VERSION=${GITHUB_SHA:0:7}" >> $GITHUB_ENV
37+
3738
- name: Build CLI
3839
run: yarn --cwd cli
39-
- name: Build Web UI Image
40-
run: docker build -t $WEBUI_TAG:$IMAGE_VERSION webui
40+
41+
- name: Log in to the Container registry
42+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
43+
with:
44+
registry: ${{ env.REGISTRY }}
45+
username: ${{ github.actor }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Extract metadata (tags, labels) for Docker
49+
id: meta
50+
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
51+
with:
52+
images: |
53+
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.WEBUI_IMAGE }}
54+
tags:
55+
type=sha,prefix=
56+
labels: |
57+
org.opencontainers.image.title=OpenVSX WebUI
58+
59+
- name: Build and push Web UI Image
60+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
61+
with:
62+
context: webui
63+
# only push to ghcr.io in the upstream repo when pushing to the master branch
64+
push: ${{ github.repository_owner == 'eclipse' && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
65+
tags: ${{ steps.meta.outputs.tags }}
66+
labels: ${{ steps.meta.outputs.labels }}
67+
68+
build-and-push-server:
69+
permissions:
70+
contents: read
71+
packages: write
72+
id-token: write
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
76+
with:
77+
persist-credentials: false
78+
79+
- name: Set up JDK
80+
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
81+
with:
82+
distribution: 'temurin'
83+
java-version: 25
84+
4185
- name: Get all changed server files
4286
id: changed_server_files
43-
uses: tj-actions/[email protected]
87+
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
4488
with:
4589
files: server/**
90+
4691
- name: Run Server Tests
4792
if: steps.changed_server_files.outputs.any_changed == 'true'
4893
run: server/gradlew --no-daemon -p server check
4994
env:
5095
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_API_TOKEN }}
51-
- name: Build Server Image
52-
run: docker build -t $SERVER_TAG:$IMAGE_VERSION server --secret id=dv-key,env=DEVELOCITY_ACCESS_KEY
96+
97+
- name: Log in to the Container registry
98+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
99+
with:
100+
registry: ${{ env.REGISTRY }}
101+
username: ${{ github.actor }}
102+
password: ${{ secrets.GITHUB_TOKEN }}
103+
104+
- name: Extract metadata (tags, labels) for Docker
105+
id: meta
106+
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
107+
with:
108+
images: |
109+
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.SERVER_IMAGE }}
110+
tags:
111+
type=sha,prefix=
112+
labels: |
113+
org.opencontainers.image.title=OpenVSX Server
114+
115+
- name: Build and push Server Image
116+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
53117
env:
54118
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_API_TOKEN }}
55-
- name: Push Docker Images
56-
run: |
57-
echo ${{ secrets.BOT_ACCESS_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
58-
docker push $SERVER_TAG:$IMAGE_VERSION
59-
docker push $WEBUI_TAG:$IMAGE_VERSION
60-
if: github.repository == 'eclipse/openvsx' && github.ref == 'refs/heads/master'
119+
with:
120+
context: server
121+
# only push to ghcr.io in the upstream repo when pushing to the master branch
122+
push: ${{ github.repository_owner == 'eclipse' && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
123+
tags: ${{ steps.meta.outputs.tags }}
124+
labels: ${{ steps.meta.outputs.labels }}
125+
secrets: |
126+
"dv-key=${{ secrets.DEVELOCITY_ACCESS_KEY }}"
127+
128+
save-pr-number:
129+
permissions:
130+
contents: none
131+
runs-on: ubuntu-latest
132+
if: github.event_name == 'pull_request'
133+
steps:
61134
- name: Save PR number to file
62-
if: github.event_name == 'pull_request'
63135
run: echo ${{ github.event.number }} > PR_NUMBER.txt
136+
64137
- name: Archive PR number
65-
if: github.event_name == 'pull_request'
66-
uses: actions/upload-artifact@v4
138+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
67139
with:
68140
name: PR_NUMBER
69141
path: PR_NUMBER.txt

.github/workflows/sonar.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ jobs:
3737
full_name: ${{ github.event.repository.full_name }}
3838
env:
3939
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
- name: Checkout head branch on push
40+
- name: Checkout head branch
4141
uses: actions/checkout@v4
42-
if: github.event.workflow_run.event == 'push' && github.event.workflow_run.head_repository.full_name == github.event.repository.full_name
4342
with:
4443
repository: ${{ github.event.workflow_run.head_repository.full_name }}
4544
ref: ${{ github.event.workflow_run.head_branch }}
4645
fetch-depth: 0
47-
- name: Checkout head branch on pull_request
46+
- name: Checkout head branch of pull_request
4847
if: github.event.workflow_run.event == 'pull_request'
4948
env:
5049
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}

webui/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@
9696
"rimraf": "^6.1.2",
9797
"source-map-loader": "^4.0.1",
9898
"style-loader": "^3.3.3",
99-
"ts-mocha": "^10.0.0",
99+
"ts-mocha": "^11.1.0",
100+
"ts-node": "^10.9.2",
100101
"typescript": "~5.1.6",
101102
"webpack": "^5.88.1",
102103
"webpack-cli": "^5.1.4"

0 commit comments

Comments
 (0)