@@ -3,27 +3,38 @@ name: CI-Docker
33on :
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
1117jobs :
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 : |
@@ -46,28 +57,61 @@ jobs:
4657 - name : Set docker tag list to include DockerHub if credentials available
4758 if : env.DOCKER_USERNAME != null
4859 run : |
49- 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
5061
5162 - name : Set docker tag list to not include DockerHub if credentials not available
5263 if : env.DOCKER_USERNAME == null
5364 run : |
54- 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
5566
5667 - name : Build and Push to container registry
5768 uses : docker/build-push-action@v5
5869 with :
5970 push : true
6071 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+ - name : Gather information for repository dispatch
79+ id : dest-repo
80+ run : if test -f ./config/repository-dispatch.ini; then cat ./config/repository-dispatch.ini >> $GITHUB_OUTPUT; fi
81+
82+ perform-repository-dispatch :
83+ needs : [build]
84+ runs-on : ubuntu-latest
85+ container :
86+ image : ubuntu:20.04
87+ options : " --user 0"
88+ timeout-minutes : 20
89+ env :
90+ DISPATCH_TOKEN : ${{ secrets.DISPATCH_TOKEN }}
91+ strategy :
92+ matrix :
93+ dest-repo : ${{ fromJson(needs.build.outputs.DEST_REPO) }}
6194
95+ steps :
6296 - name : Send Compile action
6397 run : |
64- export DISPATCH_ACTION="$(echo run_build)"
65- echo "NEW_DISPATCH_ACTION=$DISPATCH_ACTION" >> $GITHUB_ENV
98+ export DISPATCH_ACTION="$(printf 'run_build\n')"
99+ printf 'NEW_DISPATCH_ACTION=%s\n' "$DISPATCH_ACTION" >> $GITHUB_ENV
100+
101+ - name : Repository Dispatch to ${{ matrix.dest-repo }}
102+ uses : peter-evans/repository-dispatch@v3
103+ if : env.DISPATCH_TOKEN != null && !contains(matrix.dest-repo, '/')
104+ with :
105+ repository : ${{ github.repository_owner }}/${{ matrix.dest-repo }}
106+ token : ${{ secrets.DISPATCH_TOKEN }}
107+ event-type : ${{ env.NEW_DISPATCH_ACTION }}
108+ client-payload : ' {"ref": "${{ github.ref }}"}'
66109
67- - name : Repository Dispatch
110+ - name : Repository Dispatch to specific ${{ matrix.dest-repo }}
68111 uses : peter-evans/repository-dispatch@v3
69- if : env.DISPATCH_TOKEN != null
112+ if : env.DISPATCH_TOKEN != null && contains(matrix.dest-repo, '/')
70113 with :
71- repository : ${{ github.repository_owner }}/ps2toolchain
114+ repository : ${{ matrix.dest-repo }}
72115 token : ${{ secrets.DISPATCH_TOKEN }}
73116 event-type : ${{ env.NEW_DISPATCH_ACTION }}
117+ client-payload : ' {"ref": "${{ github.ref }}"}'
0 commit comments