push_complement_image.yml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # This task does not run complement tests, see tests.yaml instead.
  2. # This task does not build docker images for synapse for use on docker hub, see docker.yaml instead
  3. name: Store complement-synapse image in ghcr.io
  4. on:
  5. push:
  6. branches: [ "master" ]
  7. schedule:
  8. - cron: '0 5 * * *'
  9. workflow_dispatch:
  10. inputs:
  11. branch:
  12. required: true
  13. default: 'develop'
  14. type: choice
  15. options:
  16. - develop
  17. - master
  18. # Only run this action once per pull request/branch; restart if a new commit arrives.
  19. # C.f. https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency
  20. # and https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context
  21. concurrency:
  22. group: ${{ github.workflow }}-${{ github.ref }}
  23. cancel-in-progress: true
  24. jobs:
  25. build:
  26. name: Build and push complement image
  27. runs-on: ubuntu-latest
  28. permissions:
  29. contents: read
  30. packages: write
  31. steps:
  32. - name: Checkout specific branch (debug build)
  33. uses: actions/checkout@v3
  34. if: github.event_name == 'workflow_dispatch'
  35. with:
  36. ref: ${{ inputs.branch }}
  37. - name: Checkout clean copy of develop (scheduled build)
  38. uses: actions/checkout@v3
  39. if: github.event_name == 'schedule'
  40. with:
  41. ref: develop
  42. - name: Checkout clean copy of master (on-push)
  43. uses: actions/checkout@v3
  44. if: github.event_name == 'push'
  45. with:
  46. ref: master
  47. - name: Login to registry
  48. uses: docker/login-action@v2
  49. with:
  50. registry: ghcr.io
  51. username: ${{ github.actor }}
  52. password: ${{ secrets.GITHUB_TOKEN }}
  53. - name: Work out labels for complement image
  54. id: meta
  55. uses: docker/metadata-action@v4
  56. with:
  57. images: ghcr.io/${{ github.repository }}/complement-synapse
  58. tags: |
  59. type=schedule,pattern=nightly,enable=${{ github.event_name == 'schedule'}}
  60. type=raw,value=develop,enable=${{ github.event_name == 'schedule' || inputs.branch == 'develop' }}
  61. type=raw,value=latest,enable=${{ github.event_name == 'push' || inputs.branch == 'master' }}
  62. type=sha,format=long
  63. - name: Run scripts-dev/complement.sh to generate complement-synapse:latest image.
  64. run: scripts-dev/complement.sh --build-only
  65. - name: Tag and push generated image
  66. run: |
  67. for TAG in ${{ join(fromJson(steps.meta.outputs.json).tags, ' ') }}; do
  68. echo "tag and push $TAG"
  69. docker tag complement-synapse $TAG
  70. docker push $TAG
  71. done