Skip to content

Commit 691fc24

Browse files
committed
adopt generic iocs container build CI
1 parent 782f618 commit 691fc24

File tree

1 file changed

+57
-51
lines changed

1 file changed

+57
-51
lines changed

.github/workflows/code.yml

Lines changed: 57 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,88 @@
1-
name: Code CI
1+
name: Build and publish image to ghcr.io
22

33
on:
44
push:
5-
branches:
6-
- main
7-
tags:
8-
- "*"
95
pull_request:
106

117
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
1411
permissions:
1512
contents: read
1613
packages: write
1714

15+
runs-on: ubuntu-latest
16+
outputs:
17+
developer-tag: ${{ steps.meta-developer.outputs.tags }}
18+
1819
steps:
1920
- name: Checkout
20-
uses: actions/checkout@v2
21+
uses: actions/checkout@v4
22+
with:
23+
submodules: recursive
2124

2225
- 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
2527
with:
26-
registry: ghcr.io
28+
registry: ghcr.io/${{ github.repository_owner }}
2729
username: ${{ github.actor }}
2830
password: ${{ secrets.GITHUB_TOKEN }}
2931

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-
3932
- name: Set up Docker Buildx
40-
id: buildx
41-
uses: docker/setup-buildx-action@v1
33+
uses: docker/setup-buildx-action@v3
4234

43-
- name: Cache Docker layers
44-
uses: actions/cache@v2
35+
- name: Build image
36+
uses: docker/build-push-action@v5
4537
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
5046

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
5350
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 }}
6055
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
56+
- name: Push developer image
57+
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
58+
uses: docker/build-push-action@v5
59+
with:
60+
context: ./docker
61+
platforms: ${{ matrix.platform }}
62+
build-args: |
63+
IMAGE_EXT=${{ matrix.extension }}
64+
tags: ${{ steps.meta-developer.outputs.tags }}
65+
labels: ${{ steps.meta-developer.outputs.labels }}
66+
push: true
6867

6968
release:
70-
needs: [make-container]
71-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
72-
runs-on: "ubuntu-latest"
69+
# Release on tag push - publish ioc schema
70+
needs: [build]
71+
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
72+
runs-on: ubuntu-latest
73+
74+
# this job runs in the native developer container we just made
75+
container:
76+
image: ${{ needs.build.outputs.developer-tag }}
77+
7378
steps:
74-
- name: Checkout
75-
uses: actions/checkout@v2
79+
- name: report container tag name
80+
run: |
81+
echo developer container image tag is ${{ needs.build.outputs.developer-tag }}
7682
7783
- name: Github Release
78-
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14
84+
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
7985
with:
86+
files: |
87+
ibek.ioc.schema.json
8088
generate_release_notes: true
81-
env:
82-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)