Skip to content

Commit 9831b89

Browse files
committed
CI: improve docker CI
Sync changes with other repo Separate repository dispatch into another job Add ARM build
1 parent 9869618 commit 9831b89

1 file changed

Lines changed: 63 additions & 20 deletions

File tree

.github/workflows/docker.yml

Lines changed: 63 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,43 @@ name: CI-Docker
33
on:
44
push:
55
branches:
6+
- master
67
- main
78
tags:
89
- v*
10+
paths-ignore:
11+
- '**.md'
12+
- '**.rst'
913
workflow_dispatch: {}
14+
repository_dispatch:
15+
types: [run_build]
1016

1117
jobs:
1218
build:
13-
runs-on: ubuntu-latest
1419
env:
1520
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
1621
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
17-
DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
22+
BASE_DOCKER_IMAGE_NAME: ${{ (github.event.repository.name == 'ps2sdk' && 'ps2toolchain') || (github.event.repository.name == 'ps2sdk-ports' && 'ps2sdk') || (github.event.repository.name == 'ps2-packer' && 'ps2sdk') || (github.event.repository.name == 'ps2dev' && 'ps2sdk-ports') || 'none' }}
23+
strategy:
24+
matrix:
25+
runs-on: [ubuntu-latest, ubuntu-24.04-arm]
26+
runs-on: ${{ matrix.runs-on }}
27+
timeout-minutes: 180
1828

1929
steps:
20-
- uses: actions/checkout@v4
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
2132

2233
- name: Extract DOCKER_TAG using tag name
2334
if: startsWith(github.ref, 'refs/tags/')
2435
run: |
25-
echo "DOCKER_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
26-
36+
printf 'DOCKER_TAG=%s\n' "${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
37+
2738
- name: Use default DOCKER_TAG
2839
if: startsWith(github.ref, 'refs/tags/') != true
2940
run: |
30-
echo "DOCKER_TAG=latest" >> $GITHUB_ENV
31-
32-
- name: Set up QEMU
33-
uses: docker/setup-qemu-action@v3
34-
35-
- name: Set up Docker Buildx
36-
uses: docker/setup-buildx-action@v3
37-
41+
printf 'DOCKER_TAG=%s\n' "latest" >> $GITHUB_ENV
42+
3843
- name: Login to DockerHub
3944
uses: docker/login-action@v3
4045
if: env.DOCKER_USERNAME != null
@@ -52,28 +57,66 @@ jobs:
5257
- name: Set docker tag list to include DockerHub if credentials available
5358
if: env.DOCKER_USERNAME != null
5459
run: |
55-
echo "DOCKER_TAG_LIST=ghcr.io/${{ github.repository }}:${{ env.DOCKER_TAG }},${{ github.repository }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV
60+
printf 'DOCKER_TAG_LIST=%s\n' "ghcr.io/${{ github.repository }}:${{ env.DOCKER_TAG }},${{ github.repository }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV
5661
5762
- name: Set docker tag list to not include DockerHub if credentials not available
5863
if: env.DOCKER_USERNAME == null
5964
run: |
60-
echo "DOCKER_TAG_LIST=ghcr.io/${{ github.repository }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV
65+
printf 'DOCKER_TAG_LIST=%s\n' "ghcr.io/${{ github.repository }}:${{ env.DOCKER_TAG }}" >> $GITHUB_ENV
6166
6267
- name: Build and Push to container registry
6368
uses: docker/build-push-action@v5
6469
with:
6570
push: true
6671
tags: ${{ env.DOCKER_TAG_LIST }}
72+
build-args: |
73+
BASE_DOCKER_IMAGE=ghcr.io/${{ github.repository_owner }}/${{ env.BASE_DOCKER_IMAGE_NAME }}:${{ env.DOCKER_TAG }}
74+
BASE_DOCKER_DVP_IMAGE=ghcr.io/${{ github.repository_owner }}/ps2toolchain-dvp:${{ env.DOCKER_TAG }}
75+
BASE_DOCKER_IOP_IMAGE=ghcr.io/${{ github.repository_owner }}/ps2toolchain-iop:${{ env.DOCKER_TAG }}
76+
BASE_DOCKER_EE_IMAGE=ghcr.io/${{ github.repository_owner }}/ps2toolchain-ee:${{ env.DOCKER_TAG }}
77+
78+
perform-repository-dispatch:
79+
needs: [build]
80+
runs-on: ubuntu-latest
81+
container:
82+
image: ubuntu:20.04
83+
options: "--user 0"
84+
timeout-minutes: 20
85+
env:
86+
DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
87+
strategy:
88+
matrix:
89+
dest-repo: [ps2toolchain, ps2sdk, ps2sdk-ports, ps2-packer, ps2dev, gsKit, ps2link, ps2homebrew/ps2dev_forwarder]
90+
exclude:
91+
- dest-repo: ${{ !startsWith(github.event.repository.name, 'ps2toolchain-') && 'ps2toolchain' }}
92+
- dest-repo: ${{ github.event.repository.name != 'ps2toolchain' && 'ps2sdk' }}
93+
- dest-repo: ${{ github.event.repository.name != 'ps2sdk' && 'ps2sdk-ports' }}
94+
- dest-repo: ${{ github.event.repository.name != 'ps2sdk' && 'ps2-packer' }}
95+
- dest-repo: ${{ github.event.repository.name != 'ps2sdk-ports' && 'ps2dev' }}
96+
- dest-repo: ${{ github.event.repository.name != 'ps2sdk-ports' && 'gsKit' }}
97+
- dest-repo: ${{ github.event.repository.name != 'ps2-packer' && 'ps2link' }}
98+
- dest-repo: ${{ github.event.repository.name != 'ps2dev' && 'ps2homebrew/ps2dev_forwarder' }}
6799

100+
steps:
68101
- name: Send Compile action
69102
run: |
70-
export DISPATCH_ACTION="$(echo run_build)"
71-
echo "NEW_DISPATCH_ACTION=$DISPATCH_ACTION" >> $GITHUB_ENV
103+
export DISPATCH_ACTION="$(printf 'run_build\n')"
104+
printf 'NEW_DISPATCH_ACTION=%s\n' "$DISPATCH_ACTION" >> $GITHUB_ENV
105+
106+
- name: Repository Dispatch to ${{ matrix.dest-repo }}
107+
uses: peter-evans/repository-dispatch@v3
108+
if: env.DISPATCH_TOKEN != null && !contains(matrix.dest-repo, '/')
109+
with:
110+
repository: ${{ github.repository_owner }}/${{ matrix.dest-repo }}
111+
token: ${{ secrets.DISPATCH_TOKEN }}
112+
event-type: ${{ env.NEW_DISPATCH_ACTION }}
113+
client-payload: '{"ref": "${{ github.ref }}"}'
72114

73-
- name: Repository Dispatch
115+
- name: Repository Dispatch to specific ${{ matrix.dest-repo }}
74116
uses: peter-evans/repository-dispatch@v3
75-
if: env.DISPATCH_TOKEN != null
117+
if: env.DISPATCH_TOKEN != null && contains(matrix.dest-repo, '/')
76118
with:
77-
repository: ${{ github.repository_owner }}/ps2toolchain
119+
repository: ${{ matrix.dest-repo }}
78120
token: ${{ secrets.DISPATCH_TOKEN }}
79121
event-type: ${{ env.NEW_DISPATCH_ACTION }}
122+
client-payload: '{"ref": "${{ github.ref }}"}'

0 commit comments

Comments
 (0)