Skip to content

Commit f828ee4

Browse files
authored
feat: update github workflows to allow reuse the build workflow (#36)
* feat: update github workflows to allow reuse the build workflow * fix: fix condition to run cache related steps Signed-off-by: Denis Golovin <[email protected]>
1 parent a67d1b8 commit f828ee4

File tree

4 files changed

+65
-175
lines changed

4 files changed

+65
-175
lines changed

.github/workflows/build.yaml

+45-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ on:
66
runs-on:
77
required: true
88
type: string
9+
ext-version:
10+
required: false
11+
type: string
12+
default: latest
13+
registry:
14+
required: false
15+
type: string
916

1017
jobs:
1118
build:
@@ -21,22 +28,53 @@ jobs:
2128
with:
2229
node-version: 18
2330

24-
- name: Get yarn cache directory path
25-
id: yarn-cache-dir-path
26-
run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT"
31+
- name: Get yarn cache directory path (Windows)
32+
if: ${{ inputs.runs-on == 'windows-2022' }}
33+
id: yarn-cache-dir-path-windows
34+
run: echo "dir=$(yarn cache dir)" >> ${env:GITHUB_OUTPUT}
35+
36+
- name: Get yarn cache directory path (mac/Linux)
37+
if: ${{ inputs.runs-on == 'ubuntu-22.04' || inputs.runs-on == 'macos-14' }}
38+
id: yarn-cache-dir-path-unix
39+
run: echo "dir=$(yarn cache dir)" >> ${GITHUB_OUTPUT}
40+
41+
- uses: actions/cache@v4
42+
if: ${{ inputs.runs-on == 'windows-2022' }}
43+
id: yarn-cache-windows
44+
with:
45+
path: ${{ steps.yarn-cache-dir-path-windows.outputs.dir }}
46+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
47+
restore-keys: |
48+
${{ runner.os }}-yarn-
2749
28-
- uses: actions/cache@v3
29-
id: yarn-cache
50+
- uses: actions/cache@v4
51+
if: ${{ inputs.runs-on == 'ubuntu-22.04' || inputs.runs-on == 'macos-14' }}
52+
id: yarn-cache-unix
3053
with:
31-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
54+
path: ${{ steps.yarn-cache-dir-path-unix.outputs.dir }}
3255
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
3356
restore-keys: |
3457
${{ runner.os }}-yarn-
3558
36-
- name: yarn
59+
- name: Install dependencies (no cache found)
3760
run: |
3861
yarn --frozen-lockfile --network-timeout 180000
3962
4063
- name: Run Build
4164
timeout-minutes: 20
4265
run: yarn build
66+
67+
- name: Login to quay.io
68+
if: ${{ inputs.registry == 'quay' }}
69+
run: podman login --username ${{ secrets.QUAY_ROBOT_NAME }} --password ${{ secrets.QUAY_ROBOT_TOKEN }} quay.io
70+
71+
- name: Login to ghcr.io
72+
if: ${{ inputs.registry == 'ghrc' }}
73+
run: podman login --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }} ghcr.io
74+
75+
- name: Build and Push Image
76+
if: ${{ inputs.registry == 'ghrc' || inputs.registry == 'quay'}}
77+
id: build-image
78+
run: |
79+
podman build -t quay.io/redhat-developer/podman-desktop-redhat-account-ext:${{ inputs.ext-version }} .
80+
podman push quay.io/redhat-developer/podman-desktop-redhat-account-ext:${{ inputs.ext-version }}

.github/workflows/ci.yaml

+4-35
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,7 @@ on:
2424

2525
jobs:
2626
build:
27-
runs-on: ubuntu-latest
28-
steps:
29-
- uses: actions/checkout@v3
30-
31-
- uses: actions/setup-node@v3
32-
with:
33-
node-version: 18
34-
35-
- name: Get yarn cache directory path
36-
id: yarn-cache-dir-path
37-
run: echo "dir=$(npx yarn cache dir)" >> ${GITHUB_OUTPUT}
38-
39-
- uses: actions/cache@v3
40-
id: yarn-cache
41-
with:
42-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
43-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
44-
restore-keys: |
45-
${{ runner.os }}-yarn-
46-
47-
- name: Execute yarn
48-
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
49-
run: npx yarn --frozen-lockfile --network-timeout 180000
50-
51-
- name: Run Build
52-
run: npx yarn build
53-
54-
- name: Login to ghcr.io
55-
run: podman login --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }} ghcr.io
56-
57-
- name: Build Image
58-
id: build-image
59-
run: |
60-
podman build -t ghcr.io/${{ github.repository_owner }}/podman-desktop-redhat-account-ext:latest .
61-
podman push ghcr.io/${{ github.repository_owner }}/podman-desktop-redhat-account-ext:latest
27+
uses: redhat-developer/podman-desktop-redhat-account-ext/.github/workflows/build.yaml@main
28+
with:
29+
runs-on: ubuntu-latest
30+
registry: 'ghrc'

.github/workflows/pr-check.yaml

+7-94
Original file line numberDiff line numberDiff line change
@@ -20,97 +20,10 @@ name: pr-check
2020
on: [pull_request]
2121

2222
jobs:
23-
windows:
24-
name: Windows
25-
runs-on: windows-2022
26-
timeout-minutes: 60
27-
env:
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29-
steps:
30-
- uses: actions/checkout@v3
31-
32-
- uses: actions/setup-node@v3
33-
with:
34-
node-version: 18
35-
36-
- name: Get yarn cache directory path
37-
id: yarn-cache-dir-path
38-
run: echo "dir=$(yarn cache dir)" >> ${env:GITHUB_OUTPUT}
39-
40-
- uses: actions/cache@v3
41-
id: yarn-cache
42-
with:
43-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
44-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
45-
restore-keys: |
46-
${{ runner.os }}-yarn-
47-
48-
- name: yarn
49-
run: |
50-
yarn --frozen-lockfile --network-timeout 180000
51-
52-
- name: Run Build
53-
timeout-minutes: 20
54-
run: yarn build
55-
56-
darwin:
57-
name: macOS
58-
runs-on: macos-11
59-
timeout-minutes: 40
60-
env:
61-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62-
steps:
63-
- uses: actions/checkout@v3
64-
65-
- uses: actions/setup-node@v3
66-
with:
67-
node-version: 18
68-
69-
- name: Get yarn cache directory path
70-
id: yarn-cache-dir-path
71-
run: echo "dir=$(yarn cache dir)" >> ${GITHUB_OUTPUT}
72-
73-
- uses: actions/cache@v3
74-
id: yarn-cache
75-
with:
76-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
77-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
78-
restore-keys: |
79-
${{ runner.os }}-yarn-
80-
81-
- name: Execute yarn
82-
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
83-
run: yarn --frozen-lockfile --network-timeout 180000
84-
85-
- name: Run Build
86-
timeout-minutes: 20
87-
run: yarn build
88-
89-
linux:
90-
name: Linux
91-
runs-on: ubuntu-20.04
92-
steps:
93-
- uses: actions/checkout@v3
94-
- uses: actions/setup-node@v3
95-
with:
96-
node-version: 18
97-
98-
- name: Get yarn cache directory path
99-
id: yarn-cache-dir-path
100-
run: echo "dir=$(yarn cache dir)" >> ${GITHUB_OUTPUT}
101-
102-
- uses: actions/cache@v3
103-
id: yarn-cache
104-
with:
105-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
106-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
107-
restore-keys: |
108-
${{ runner.os }}-yarn-
109-
110-
- name: Execute yarn
111-
run: yarn --frozen-lockfile
112-
113-
- name: Run Build
114-
timeout-minutes: 20
115-
run: yarn build
116-
23+
pr-check-job:
24+
strategy:
25+
matrix:
26+
target: [windows-2022, macos-14, ubuntu-20.04]
27+
uses: redhat-developer/podman-desktop-redhat-account-ext/.github/workflows/build.yaml@main
28+
with:
29+
runs-on: ${{ matrix.target }}

.github/workflows/release.yaml

+9-39
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
- uses: actions/checkout@v3
4545
with:
4646
ref: ${{ github.event.inputs.branch }}
47+
4748
- name: Generate tag utilities
4849
id: TAG_UTIL
4950
run: |
@@ -64,6 +65,7 @@ jobs:
6465
echo "Tagging with ${{ steps.TAG_UTIL.outputs.githubTag }}"
6566
git tag ${{ steps.TAG_UTIL.outputs.githubTag }}
6667
git push origin ${{ steps.TAG_UTIL.outputs.githubTag }}
68+
6769
- name: Create Release
6870
id: create_release
6971
uses: ncipollo/release-action@v1
@@ -77,56 +79,24 @@ jobs:
7779

7880
build:
7981
needs: [tag]
80-
runs-on: ubuntu-latest
81-
steps:
82-
- uses: actions/checkout@v3
83-
with:
84-
ref: ${{ github.event.inputs.branch }}
85-
86-
- uses: actions/setup-node@v3
87-
with:
88-
node-version: 18
89-
90-
- name: Get yarn cache directory path
91-
id: yarn-cache-dir-path
92-
run: echo "dir=$(npx yarn cache dir)" >> ${GITHUB_OUTPUT}
93-
94-
- uses: actions/cache@v3
95-
id: yarn-cache
96-
with:
97-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
98-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
99-
restore-keys: |
100-
${{ runner.os }}-yarn-
101-
102-
- name: Execute yarn
103-
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
104-
run: npx yarn --frozen-lockfile --network-timeout 180000
105-
106-
- name: Run Build
107-
run: npx yarn build
108-
109-
- name: Login to quay.io
110-
run: podman login --username ${{ secrets.QUAY_ROBOT_NAME }} --password ${{ secrets.QUAY_ROBOT_TOKEN }} quay.io
111-
112-
- name: Build Image
113-
id: build-image
114-
run: |
115-
podman build -t quay.io/redhat-developer/podman-desktop-redhat-account-ext:${{ needs.tag.outputs.extVersion }} .
116-
podman push quay.io/redhat-developer/podman-desktop-redhat-account-ext:${{ needs.tag.outputs.extVersion }}
82+
uses: redhat-developer/podman-desktop-redhat-account-ext/.github/workflows/build.yaml@main
83+
with:
84+
runs-on: ubuntu-latest
85+
registry: quay
86+
ext-version: ${{ needs.tag.outputs.extVersion }}
11787

11888
release:
11989
needs: [tag, build]
12090
name: Release
12191
runs-on: ubuntu-20.04
12292
steps:
12393
- name: id
124-
run: echo the release id is ${{ needs.tag.outputs.releaseId}}
94+
run: echo the release id is ${{ needs.tag.outputs.releaseId }}
12595

12696
- name: Publish release
12797
uses: StuYarrow/[email protected]
12898
env:
12999
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130100
with:
131-
id: ${{ needs.tag.outputs.releaseId}}
101+
id: ${{ needs.tag.outputs.releaseId }}
132102

0 commit comments

Comments
 (0)