Skip to content

Commit 5d45cfc

Browse files
committed
adopt generic iocs container build CI
1 parent 782f618 commit 5d45cfc

File tree

1 file changed

+59
-51
lines changed

1 file changed

+59
-51
lines changed

.github/workflows/code.yml

Lines changed: 59 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,90 @@
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+
target: runtime
41+
build-args: |
42+
IMAGE_EXT=${{ matrix.extension }}
43+
cache-from: type=gha,scope=${{ matrix.epics-target }}
44+
cache-to: type=gha,mode=max,scope=${{ matrix.epics-target }}
45+
tags: ci_test
46+
load: true
5047

51-
- name: Build runtime image
52-
uses: docker/build-push-action@v2
48+
- name: Developer target metadata
49+
id: meta-developer
50+
uses: docker/metadata-action@v3
5351
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
52+
images: |
53+
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
54+
tags: |
55+
type=raw,value=${{ github.ref_name }}
6056
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+
target: developer
64+
build-args: |
65+
IMAGE_EXT=${{ matrix.extension }}
66+
tags: ${{ steps.meta-developer.outputs.tags }}
67+
labels: ${{ steps.meta-developer.outputs.labels }}
68+
push: true
6869

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

0 commit comments

Comments
 (0)