|
1 | | -name: Code CI |
| 1 | +name: Build and publish image to ghcr.io |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: |
6 | | - - main |
7 | | - tags: |
8 | | - - "*" |
9 | 5 | pull_request: |
10 | 6 |
|
11 | 7 | jobs: |
12 | | - make-container: |
13 | | - runs-on: ubuntu-latest |
| 8 | + build: |
| 9 | + # pull requests are a duplicate of a branch push if within the same repo. |
| 10 | + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository |
14 | 11 | permissions: |
15 | 12 | contents: read |
16 | 13 | packages: write |
17 | 14 |
|
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + developer-tag: ${{ steps.meta-developer.outputs.tags }} |
| 18 | + |
18 | 19 | steps: |
19 | 20 | - name: Checkout |
20 | | - uses: actions/checkout@v2 |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + submodules: recursive |
21 | 24 |
|
22 | 25 | - name: Log in to GitHub Docker Registry |
23 | | - if: github.event_name != 'pull_request' |
24 | | - uses: docker/login-action@v1 |
| 26 | + uses: docker/login-action@v3 |
25 | 27 | with: |
26 | | - registry: ghcr.io |
| 28 | + registry: ghcr.io/${{ github.repository_owner }} |
27 | 29 | username: ${{ github.actor }} |
28 | 30 | password: ${{ secrets.GITHUB_TOKEN }} |
29 | 31 |
|
30 | | - - name: Docker meta |
31 | | - id: meta |
32 | | - uses: docker/metadata-action@v4 |
33 | | - with: |
34 | | - images: ghcr.io/${{ github.repository }} |
35 | | - tags: | |
36 | | - type=ref,event=tag |
37 | | - type=raw,value=latest |
38 | | -
|
39 | 32 | - name: Set up Docker Buildx |
40 | | - id: buildx |
41 | | - uses: docker/setup-buildx-action@v1 |
| 33 | + uses: docker/setup-buildx-action@v3 |
42 | 34 |
|
43 | | - - name: Cache Docker layers |
44 | | - uses: actions/cache@v2 |
| 35 | + - name: Build image |
| 36 | + uses: docker/build-push-action@v5 |
45 | 37 | with: |
46 | | - path: /tmp/.buildx-cache |
47 | | - key: ${{ runner.os }}-buildx-${{ github.sha }} |
48 | | - restore-keys: | |
49 | | - ${{ runner.os }}-buildx- |
| 38 | + context: ./docker |
| 39 | + platforms: ${{ matrix.platform }} |
| 40 | + build-args: | |
| 41 | + IMAGE_EXT=${{ matrix.extension }} |
| 42 | + cache-from: type=gha,scope=${{ matrix.epics-target }} |
| 43 | + cache-to: type=gha,mode=max,scope=${{ matrix.epics-target }} |
| 44 | + tags: ci_test |
| 45 | + load: true |
50 | 46 |
|
51 | | - - name: Build runtime image |
52 | | - uses: docker/build-push-action@v2 |
| 47 | + - name: Developer target metadata |
| 48 | + id: meta-developer |
| 49 | + uses: docker/metadata-action@v3 |
53 | 50 | with: |
54 | | - context: docker |
55 | | - push: ${{ github.event_name != 'pull_request' }} |
56 | | - tags: ${{ steps.meta.outputs.tags }} |
57 | | - labels: ${{ steps.meta.outputs.labels }} |
58 | | - cache-from: type=local,src=/tmp/.buildx-cache |
59 | | - cache-to: type=local,dest=/tmp/.buildx-cache-new |
| 51 | + images: | |
| 52 | + ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} |
| 53 | + tags: | |
| 54 | + type=raw,value=${{ github.ref_name }} |
| 55 | + type=raw,value=latest |
60 | 56 |
|
61 | | - # Stop the cache growing indefinitely (remove when the below is fixed) |
62 | | - # When removing this change cache-to above |
63 | | - # https://github.com/docker/build-push-action/issues/252#issuecomment-744400434 |
64 | | - - name: Move cache |
65 | | - run: | |
66 | | - rm -rf /tmp/.buildx-cache |
67 | | - mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
| 57 | + - name: Push developer image |
| 58 | + if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} |
| 59 | + uses: docker/build-push-action@v5 |
| 60 | + with: |
| 61 | + context: ./docker |
| 62 | + platforms: ${{ matrix.platform }} |
| 63 | + build-args: | |
| 64 | + IMAGE_EXT=${{ matrix.extension }} |
| 65 | + tags: ${{ steps.meta-developer.outputs.tags }} |
| 66 | + labels: ${{ steps.meta-developer.outputs.labels }} |
| 67 | + push: true |
68 | 68 |
|
69 | 69 | release: |
70 | | - needs: [make-container] |
71 | | - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
72 | | - runs-on: "ubuntu-latest" |
73 | | - steps: |
74 | | - - name: Checkout |
75 | | - uses: actions/checkout@v2 |
| 70 | + # Release on tag push - publish ioc schema |
| 71 | + needs: [build] |
| 72 | + if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} |
| 73 | + runs-on: ubuntu-latest |
76 | 74 |
|
| 75 | + steps: |
77 | 76 | - name: Github Release |
78 | | - uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14 |
| 77 | + uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15 |
79 | 78 | with: |
| 79 | + files: | |
| 80 | + ibek.ioc.schema.json |
80 | 81 | generate_release_notes: true |
81 | | - env: |
82 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments