Skip to content

Commit 1ce86ad

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

File tree

1 file changed

+63
-52
lines changed

1 file changed

+63
-52
lines changed

.github/workflows/code.yml

Lines changed: 63 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,93 @@
1-
name: Code CI
1+
name: Build and publish image to ghcr.io/epics-containers
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
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
epics-target: [linux-x86_64]
18+
19+
runs-on: ${{ matrix.os }}
20+
outputs:
21+
developer-tag: ${{ steps.meta-developer.outputs.tags }}
1722

1823
steps:
1924
- name: Checkout
20-
uses: actions/checkout@v2
25+
uses: actions/checkout@v4
26+
with:
27+
submodules: recursive
2128

2229
- name: Log in to GitHub Docker Registry
23-
if: github.event_name != 'pull_request'
24-
uses: docker/login-action@v1
30+
uses: docker/login-action@v3
2531
with:
26-
registry: ghcr.io
32+
registry: ghcr.io/${{ github.repository_owner }}
2733
username: ${{ github.actor }}
2834
password: ${{ secrets.GITHUB_TOKEN }}
2935

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

43-
- name: Cache Docker layers
44-
uses: actions/cache@v2
39+
- name: Build image
40+
uses: docker/build-push-action@v5
4541
with:
46-
path: /tmp/.buildx-cache
47-
key: ${{ runner.os }}-buildx-${{ github.sha }}
48-
restore-keys: |
49-
${{ runner.os }}-buildx-
42+
context: .
43+
platforms: ${{ matrix.platform }}
44+
target: runtime
45+
build-args: |
46+
IMAGE_EXT=${{ matrix.extension }}
47+
cache-from: type=gha,scope=${{ matrix.epics-target }}
48+
cache-to: type=gha,mode=max,scope=${{ matrix.epics-target }}
49+
tags: ci_test
50+
load: true
5051

51-
- name: Build runtime image
52-
uses: docker/build-push-action@v2
52+
- name: Developer target metadata
53+
id: meta-developer
54+
uses: docker/metadata-action@v3
5355
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
60-
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+
images: |
57+
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
58+
tags: |
59+
type=raw,value=${{ github.ref_name }}
6860
61+
- name: Push developer image
62+
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
63+
uses: docker/build-push-action@v5
64+
with:
65+
context: .
66+
platforms: ${{ matrix.platform }}
67+
target: developer
68+
build-args: |
69+
IMAGE_EXT=${{ matrix.extension }}
70+
tags: ${{ steps.meta-developer.outputs.tags }}
71+
labels: ${{ steps.meta-developer.outputs.labels }}
72+
push: true
6973
release:
70-
needs: [make-container]
71-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
72-
runs-on: "ubuntu-latest"
74+
# Release on tag push - publish ioc schema
75+
needs: [build]
76+
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
77+
runs-on: ubuntu-latest
78+
79+
# this job runs in the native developer container we just made
80+
container:
81+
image: ${{ needs.build.outputs.developer-tag }}
82+
7383
steps:
74-
- name: Checkout
75-
uses: actions/checkout@v2
84+
- name: report container tag name
85+
run: |
86+
echo developer container image tag is ${{ needs.build.outputs.developer-tag }}
7687
7788
- name: Github Release
78-
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14
89+
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
7990
with:
91+
files: |
92+
ibek.ioc.schema.json
8093
generate_release_notes: true
81-
env:
82-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)