Skip to content

Commit 5c872ab

Browse files
add manifest action and update workflow
1 parent 82af8ae commit 5c872ab

2 files changed

Lines changed: 171 additions & 20 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: 'Manifest'
2+
inputs:
3+
head_sha:
4+
required: true
5+
artifact_name:
6+
required: true
7+
artifact_image_file:
8+
required: true
9+
artifact_image_name:
10+
required: true
11+
arch:
12+
required: true
13+
image:
14+
required: true
15+
default: ghcr.io/${{ github.repository }}:latest
16+
registry:
17+
required: true
18+
default: ghcr.io
19+
username:
20+
required: true
21+
default: ${{ github.actor }}
22+
password:
23+
required: true
24+
default: ${{ github.token }}
25+
runs:
26+
using: "composite"
27+
steps:
28+
-
29+
uses: actions/download-artifact@v4
30+
with:
31+
name: ${{ inputs.artifact_name }}
32+
path: /tmp/
33+
-
34+
shell: bash
35+
run: docker load -i /tmp/${{ inputs.artifact_image_file }}
36+
-
37+
id: image_parts
38+
shell: bash
39+
run: |
40+
IMAGE_TAGLESS=$(echo ${{ inputs.image }} | cut -d':' -f1)
41+
IMAGE_REPO=$(echo $IMAGE_TAGLESS | cut -d'/' -f2,3)
42+
IMAGE_TAG=$(echo ${{ inputs.image }} | cut -d':' -f2)
43+
echo "::set-output name=repo::$IMAGE_REPO"
44+
echo "::set-output name=tag::$IMAGE_TAG"
45+
-
46+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
47+
with:
48+
registry: ${{ inputs.registry }}
49+
username: ${{ inputs.username }}
50+
password: ${{ inputs.password }}
51+
-
52+
shell: bash
53+
run: echo "IMAGE_URL=https://${{ inputs.image }}" >> $GITHUB_ENV
54+
-
55+
if: ${{ inputs.registry == 'docker.io' }}
56+
shell: bash
57+
run: |
58+
echo "IMAGE_URL=https://hub.docker.com/r/${{ steps.image_parts.outputs.repo }}/tags?name=${{ steps.image_parts.outputs.tag }}" >> $GITHUB_ENV
59+
-
60+
shell: bash
61+
run: |
62+
docker push ${{ inputs.image }}
63+
-
64+
uses: actions/github-script@v5
65+
with:
66+
script: |
67+
github.rest.repos.createCommitStatus({
68+
owner: context.repo.owner,
69+
repo: context.repo.repo,
70+
sha: '${{ inputs.head_sha }}',
71+
state: 'success',
72+
context: `${{ inputs.image }}`,
73+
target_url: '${{ env.IMAGE_URL }}',
74+
description: 'Available',
75+
});

.github/workflows/newbuild.yml

Lines changed: 96 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ concurrency:
1616

1717
env:
1818
sha: ${{ github.event.pull_request.head.sha || github.sha }}
19-
image: ${{ format('{0}/{1}', secrets.DOCKERHUB_TOKEN && 'docker.io' || 'ghcr.io', github.repository) }}
19+
image_repo: ${{ format('{0}/{1}', secrets.DOCKERHUB_TOKEN && 'docker.io' || 'ghcr.io', github.repository) }}
2020
# Cache ID is a value inserted into cache keys. Whenever changing the build
2121
# in a way that needs to use entirely new fresh builds, increment the number
2222
# by one so that all the keys become new.
@@ -27,13 +27,13 @@ env:
2727

2828
jobs:
2929

30-
#complete:
31-
# if: always()
32-
# needs: [build, test]
33-
# runs-on: ubuntu-latest
34-
# steps:
35-
# - if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
36-
# run: exit 1
30+
complete:
31+
if: always()
32+
needs: [setup, load, build, test, push]
33+
runs-on: ubuntu-latest
34+
steps:
35+
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
36+
run: exit 1
3737

3838
setup:
3939
runs-on: ubuntu-latest
@@ -153,7 +153,7 @@ jobs:
153153
dep: ${{ fromJSON(needs.prepare.outputs.deps-to-build) }}
154154
fail-fast: false
155155
name: build ${{ matrix.dep.name }} ${{ matrix.dep.repo }} ${{ matrix.dep.ref }} ${{ matrix.dep.arch }} ${{ matrix.dep.options && toJSON(matrix.dep.options) }}
156-
runs-on: ${{ matrix.dep.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
156+
runs-on: ${{ matrix.dep.name == 'core' && (matrix.dep.arch == 'arm64' && 'ubuntu-jammy-16-cores-amd64' || 'ubuntu-latest-16-cores') || (matrix.dep.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest') }}
157157
env:
158158
image_filename: image-${{ matrix.dep.name }}-${{ matrix.dep.id }}-${{ matrix.dep.arch }}.tar
159159
steps:
@@ -215,9 +215,9 @@ jobs:
215215
< "${image/%.tar/.json}" jq
216216
docker load -i $image
217217
done
218-
- name: Create Full Tag Name
218+
- name: Create Tag
219219
id: tag
220-
run: echo "tag=${{ enV.image }}${{ needs.setup.outputs.tag-prefix }}${{ matrix.image.tag }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT
220+
run: echo "tag=${{ needs.setup.outputs.tag-prefix }}-${{ matrix.image.tag }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT
221221
- name: Pull Base Image
222222
run: docker pull --platform linux/${{ matrix.arch }} ubuntu:22.04
223223
# Docker buildx cannot be used to build the dev quickstart image because
@@ -231,7 +231,7 @@ jobs:
231231
docker build
232232
--platform linux/${{ matrix.arch }}
233233
-f Dockerfile
234-
-t ${{ steps.tag.outputs.tag }}
234+
-t ${{ env.image_repo }}:${{ steps.tag.outputs.tag }}
235235
--label org.opencontainers.image.revision="${{ env.sha }}"
236236
.
237237
--build-arg REVISION="${{ env.sha }}"
@@ -286,33 +286,33 @@ jobs:
286286
df -h
287287
- uses: actions/checkout@v2
288288
with:
289-
ref: ${{ inputs.sha }}
289+
ref: ${{ env.sha }}
290290
- name: Download Quickstart Image
291291
uses: actions/download-artifact@v4
292292
with:
293-
name: image-quickstart-${{ matrix.tag }}-${{ inputs.arch }}
293+
name: image-quickstart-${{ matrix.tag }}-${{ matrix.arch }}
294294
path: /tmp/
295295
- name: Load Quickstart Image
296296
run: docker load -i /tmp/image
297297
- if: inputs.arch == 'arm64'
298298
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18
299299
with:
300300
platforms: arm64
301-
- name: Create Full Tag Name
301+
- name: Create Tag
302302
id: tag
303-
run: echo "tag=${{ env.image }}${{ needs.setup.outputs.tag-prefix }}${{ matrix.tag }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT
303+
run: echo "tag=${{ needs.setup.outputs.tag-prefix }}-${{ matrix.tag }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT
304304
- name: Prepare Logs Directory
305305
run: mkdir -p logs
306306
- name: Run Quickstart Image
307307
run: >
308308
docker run
309-
--platform linux/${{ inputs.arch }}
309+
--platform linux/${{ matrix.arch }}
310310
-d
311311
-p
312312
"8000:8000"
313313
-p "11626:11626"
314314
--name stellar
315-
${{ steps.tag.outputs.tag }}
315+
${{ env.image_repo }}:${{ steps.tag.outputs.tag }}
316316
--${{ matrix.network }}
317317
--enable ${{ matrix.core && 'core' }},${{ matrix.rpc && 'rpc' }},${{ matrix.horizon && 'horizon' }}
318318
${{ matrix.options }}
@@ -377,6 +377,82 @@ jobs:
377377
if: always()
378378
uses: actions/upload-artifact@v4
379379
with:
380-
name: logs-${{ inputs.tag }}-${{ inputs.arch }}-test-${{ strategy.job-index }}
380+
name: logs-${{ matrix.tag }}-${{ matrix.arch }}-test-${{ strategy.job-index }}
381381
path: logs
382-
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS_FOR_LOGS }}
382+
retention-days: ${{ env.artifact_retention_days_for_logs }}
383+
384+
push:
385+
needs: test
386+
if: always() && !failure() && !cancelled() && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository))
387+
strategy:
388+
matrix:
389+
tag: ${{ fromJSON(needs.setup.outputs.images).*.tag }}
390+
arch: ["amd64", "arm64"]
391+
fail-fast: false
392+
permissions:
393+
packages: write
394+
statuses: write
395+
runs-on: ubuntu-latest
396+
steps:
397+
- uses: actions/checkout@v2
398+
with:
399+
ref: ${{ inputs.sha }}
400+
- name: Create Tag
401+
id: tag
402+
run: echo "tag=${{ needs.setup.outputs.tag-prefix }}-${{ matrix.tag }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT
403+
- uses: ./.github/actions/push
404+
with:
405+
head_sha: ${{ env.sha }}
406+
artifact_name: image-quickstart-${{ matrix.tag }}-${{ matrix.arch }}
407+
artifact_image_file: image
408+
arch: ${{ matrix.arch }}
409+
image: ${{ env.image_repo }}:${{ steps.tag.outputs.tag }}
410+
registry: ${{ secrets.DOCKERHUB_TOKEN && 'docker.io' || 'ghcr.io' }}
411+
username: ${{ secrets.DOCKERHUB_USERNAME || github.actor }}
412+
password: ${{ secrets.DOCKERHUB_TOKEN || github.token }}
413+
414+
manifest:
415+
needs: push
416+
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
417+
strategy:
418+
matrix:
419+
tag: ${{ fromJSON(needs.setup.outputs.images).*.tag }}
420+
fail-fast: false
421+
permissions:
422+
packages: write
423+
statuses: write
424+
runs-on: ubuntu-latest
425+
steps:
426+
- name: Create Tag
427+
id: tag
428+
run: echo "tag=${{ needs.setup.outputs.tag-prefix }}-${{ matrix.tag }}" >> $GITHUB_OUTPUT
429+
run: echo "tag-alias=${{ needs.setup.outputs.tag-alias-prefix }}-${{ matrix.tag }}" >> $GITHUB_OUTPUT
430+
- uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
431+
with:
432+
registry: ${{ env.REGISTRY }}
433+
username: ${{ secrets.DOCKERHUB_USERNAME || github.actor }}
434+
password: ${{ secrets.DOCKERHUB_TOKEN || github.token }}
435+
- run: >
436+
docker manifest create
437+
${{ env.image_repo }}:${{ steps.tag.outputs.tag }}
438+
${{ env.image_repo }}:${{ steps.tag.outputs.tag }}-amd64
439+
${{ env.image_repo }}:${{ steps.tag.outputs.tag }}-arm64
440+
- run: >
441+
docker manifest push
442+
${{ env.image_repo }}:${{ steps.tag.outputs.tag }}
443+
- run: >
444+
docker buildx imagetools create -t
445+
${{ env.image_repo }}:${{ steps.tag.outputs.tag-alias }}
446+
${{ env.image_repo }}:${{ steps.tag.outputs.tag }}
447+
- uses: actions/github-script@v5
448+
with:
449+
script: |
450+
github.rest.repos.createCommitStatus({
451+
owner: context.repo.owner,
452+
repo: context.repo.repo,
453+
sha: '${{ env.HEAD_SHA }}',
454+
state: 'success',
455+
context: `${{ env.IMAGE }}`,
456+
target_url: '${{ env.IMAGE_URL }}',
457+
description: 'Available',
458+
});

0 commit comments

Comments
 (0)