@@ -2,6 +2,8 @@ name: Openfire CI
2
2
3
3
env :
4
4
CI : true
5
+ REGISTRY : ghcr.io
6
+ IMAGE_NAME : openfire
5
7
6
8
on : [push, pull_request]
7
9
@@ -237,18 +239,6 @@ jobs:
237
239
- '.github/workflows/continuous-integration-workflow.yml'
238
240
- 'xmppserver/pom.xml'
239
241
240
- docker :
241
- name : Build (and maybe push) Docker image
242
- needs :
243
- - check_branch
244
- runs-on : ubuntu-latest
245
- steps : # could log into docker hub here, so we can push the image.
246
- - name : Build docker image
247
- uses : docker/build-push-action@v6
248
- with :
249
- push : false # # ${{ needs.check_branch.output.is_publishable_branch == 'true' }}
250
- tags : openfire:${{ needs.check_branch.outputs.branch_tag }}
251
-
252
242
sqlserver :
253
243
name : Test SQL Server Upgrades
254
244
needs : [build, should-do-database-upgrade-tests, check_branch]
@@ -398,131 +388,52 @@ jobs:
398
388
IGNITE_REALTIME_MAVEN_USERNAME : ${{ secrets.IGNITE_REALTIME_MAVEN_USERNAME }}
399
389
IGNITE_REALTIME_MAVEN_PASSWORD : ${{ secrets.IGNITE_REALTIME_MAVEN_PASSWORD }}
400
390
401
- can-publish-docker :
402
-
403
- # Based on https://github.com/GabLeRoux/github-actions-examples/blob/e0468ce2731b08bd8b1f7cd09d0b94c541310693/.github/workflows/secret_based_conditions.yml
404
- name : Check if Docker Hub secrets exist
391
+ build-and-push-docker :
392
+ name : Publish to GitHub's Docker registry
405
393
runs-on : ubuntu-latest
406
394
needs : [build, aioxmpp, connectivity, smack]
407
- outputs :
408
- is_DOCKERHUB_SECRET_set : ${{ steps.checksecret_job.outputs.is_DOCKERHUB_SECRET_set }}
409
- steps :
410
- - name : Check whether Docker Publish should be done
411
- id : checksecret_job
412
- env :
413
- DOCKERHUB_SECRET : ${{ secrets.DOCKERHUB_TOKEN }}
414
- run : |
415
- echo "is_DOCKERHUB_SECRET_set: ${{ env.DOCKERHUB_SECRET != '' }}"
416
- echo "is_DOCKERHUB_SECRET_set=${{ env.DOCKERHUB_SECRET != '' }}" >> $GITHUB_OUTPUT
417
-
418
-
419
- publish-docker :
420
-
421
- name : Publish to Docker Hub
422
- runs-on : ubuntu-latest
423
- needs : [can-publish-docker]
424
395
if : |
425
- needs.can-publish-docker.outputs.is_DOCKERHUB_SECRET_set == 'true' &&
426
396
github.event_name == 'push' &&
427
397
(contains(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
428
398
429
- outputs :
430
- imagedigest : ${{ steps.docker_build.outputs.digest }}
431
-
432
- steps :
433
- - name : Set up variables if we're on main
434
- if : ${{ github.ref == 'refs/heads/main' }}
435
- run : echo "SOURCE_TAG=alpha" >> $GITHUB_ENV
436
-
437
- - name : Set up variables if we're on a tag
438
- if : ${{ contains(github.ref, 'refs/tags/') }}
439
- run : echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
440
-
441
- - uses : actions/checkout@v4
442
- with :
443
- # Defend against another commit quickly following the first
444
- # We want the one that's been tested, rather than the head of main
445
- ref : ${{ github.event.push.after }}
446
-
447
- - name : Download distribution artifact from build job.
448
- uses : actions/download-artifact@v4
449
- with :
450
- name : distribution-java17
451
- path : distribution/target/distribution-base
452
-
453
- - name : Fix file permissions
454
- run : find . -type f -name '*.sh' -exec chmod +x {} \;
399
+ permissions :
400
+ contents : read
401
+ packages : write
402
+ attestations : write
403
+ id-token : write
455
404
456
- - name : Set up QEMU
457
- uses : docker/setup-qemu-action@v3
458
-
459
- - name : Set up Docker Buildx
460
- uses : docker/setup-buildx-action@v3
405
+ steps :
406
+ - name : Checkout repository
407
+ uses : actions/checkout@v4
461
408
462
- - name : Cache Docker layers # TODO: Validate that caches are faster than no caches
463
- uses : actions/cache@v4
409
+ - name : Log in to the Container registry
410
+ uses : docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
464
411
with :
465
- path : /tmp/.buildx-cache
466
- key : ${{ runner.os }}-buildx-${{ github.sha }}
467
- restore-keys : |
468
- ${{ runner.os }}-buildx-
412
+ registry : ${{ env.REGISTRY }}
413
+ username : ${{ github.actor }}
414
+ password : ${{ secrets.GITHUB_TOKEN }}
469
415
470
- - name : Login to DockerHub
471
- uses : docker/login-action@v3
416
+ - name : Extract metadata (tags, labels) for image registry
417
+ id : meta
418
+ uses : docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
472
419
with :
473
- username : ${{ secrets.DOCKERHUB_USERNAME }}
474
- password : ${{ secrets.DOCKERHUB_TOKEN }}
420
+ images : ${{ env.REGISTRY }}/Openfire/${{ env.IMAGE_NAME }}
475
421
476
- - name : Build and push to Docker Hub
477
- id : docker_build
478
- uses : docker/build-push-action@v6
422
+ - name : Build and push Docker image
423
+ id : push
424
+ uses : docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
479
425
with :
480
426
context : .
481
427
push : true
482
- tags : ${{ secrets.DOCKERHUB_OPENFIREIMAGE }}:${{ env.SOURCE_TAG }}
483
- platforms : linux/amd64,linux/arm64
484
- cache-from : type=local,src=/tmp/.buildx-cache
485
- cache-to : type=local,dest=/tmp/.buildx-cache-new
486
-
487
- - name : Move cache
488
- # Temp fix
489
- # https://github.com/docker/build-push-action/issues/252
490
- # https://github.com/moby/buildkit/issues/1896
491
- run : |
492
- rm -rf /tmp/.buildx-cache
493
- mv /tmp/.buildx-cache-new /tmp/.buildx-cache
494
-
495
- - name : Image digest
496
- run : |
497
- echo Images published:
498
- echo ${{ secrets.DOCKERHUB_OPENFIREIMAGE }}:${{ steps.docker_build.outputs.digest }}
499
- echo ${{ secrets.DOCKERHUB_OPENFIREIMAGE }}:${{ env.SOURCE_TAG }}
500
-
501
- test-published-docker :
502
- name : Test tagged images published to Docker Hub
503
- runs-on : ubuntu-latest
504
- needs : [publish-docker]
505
- if : contains(github.ref, 'refs/tags/')
428
+ tags : ${{ steps.meta.outputs.tags }}
429
+ labels : ${{ steps.meta.outputs.labels }}
506
430
507
- steps :
508
- - name : Launch & Check Openfire
509
- run : |
510
- docker run --name openfire -d -p 9090:9090 ${{ secrets.DOCKERHUB_OPENFIREIMAGE }}@${{needs.publish-docker.outputs.imagedigest}}
511
-
512
- attempt_counter=0
513
- max_attempts=30
514
- until $(curl --output /dev/null --silent --head --fail http://127.0.0.1:9090); do
515
- if [ ${attempt_counter} -eq ${max_attempts} ];then
516
- echo "Max attempts reached. Openfire failed to launch."
517
- exit 1
518
- fi
519
-
520
- printf '.'
521
- attempt_counter=$(($attempt_counter+1))
522
- sleep 1
523
- done
524
- echo "Openfire Admin is reachable."
525
- docker logs openfire
431
+ - name : Generate artifact attestation
432
+ uses : actions/attest-build-provenance@v1
433
+ with :
434
+ subject-name : ${{ env.REGISTRY }}/Openfire/${{ env.IMAGE_NAME}}
435
+ subject-digest : ${{ steps.push.outputs.digest }}
436
+ push-to-registry : true
526
437
527
438
build-deb-artifact :
528
439
name : Generate DEB artifact
0 commit comments