summary refs log tree commit diff
path: root/.github/workflows/push_complement_image.yml
blob: 937bbcbad06a69ecac0235e254f65ae6e8217356 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# This task does not run complement tests, see tests.yaml instead.
# This task does not build docker images for synapse for use on docker hub, see docker.yaml instead

name: Store complement-synapse image in ghcr.io
on:
  push:
    branches: [ "master" ]
  schedule:
    - cron: '0 5 * * *'
  workflow_dispatch:
    inputs:
      branch:
        required: true
        default: 'develop'
        type: choice
        options:
          - develop
          - master

# Only run this action once per pull request/branch; restart if a new commit arrives.
# C.f. https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency
# and https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build:
    name: Build and push complement image
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - name: Checkout specific branch (debug build)
        uses: actions/checkout@v3
        if: 'github.event.type == "workflow_dispatch"'
        with:
          ref: ${{ inputs.branch }}
      - name: Checkout clean copy of develop (scheduled build)
        uses: actions/checkout@v3
        if: 'github.event.type == "schedule"'
        with:
          ref: develop
      - name: Checkout clean copy of master (on-push)
        uses: actions/checkout@v3
        if: 'github.event.type == "push"'
        with:
          ref: master
      - name: Login to registry
        uses: docker/login-action@v1
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Work out labels for complement image
        id: meta
        uses: docker/metadata-action@v1
        with:
          images: ghcr.io/${{ github.repository }}/complement-synapse
      - name: Build complement image
        run: scripts-dev/complement.sh --build-only
      - name: Tag and push generated image
        run: |
          for TAG in ${{ steps.meta.outputs.tags }}; do 
            docker tag complement-synapse:latest $TAG
            docker push $TAG
          done