Skip to content

Commit bd47e74

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

File tree

1 file changed

+51
-52
lines changed

1 file changed

+51
-52
lines changed

.github/workflows/code.yml

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,81 @@
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 }}
55+
type=raw,value=latest
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+
build-args: |
64+
IMAGE_EXT=${{ matrix.extension }}
65+
tags: ${{ steps.meta-developer.outputs.tags }}
66+
labels: ${{ steps.meta-developer.outputs.labels }}
67+
push: true
6868

6969
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
7674

75+
steps:
7776
- name: Github Release
78-
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14
77+
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
7978
with:
79+
files: |
80+
ibek.ioc.schema.json
8081
generate_release_notes: true
81-
env:
82-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)