-
Notifications
You must be signed in to change notification settings - Fork 13
136 lines (119 loc) · 3.77 KB
/
civ2.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: CIv2
on:
push:
# branches:
# - main
permissions:
id-token: write
contents: read
packages: write
env:
AWS_REGION: eu-central-1
AWS_ROLE_ARN: arn:aws:iam::332405224602:role/ci
ECR_REGISTRY: 332405224602.dkr.ecr.eu-central-1.amazonaws.com
jobs:
discover:
runs-on: ubuntu-latest
container:
image: ghcr.io/input-output-hk/catalyst-core/ci:latest
defaults:
run:
shell: bash
working-directory: /workspace
outputs:
json: ${{ steps.discover.outputs.json }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/setup-workspace
- name: Discover Earthfiles
id: discover
run: |
#JSON_OUTPUT=$(ci scan -jit docker ./containers ./src ./services ./utilities)
JSON_OUTPUT=$(ci scan -jit docker ./containers)
JSON_OUTPUT_FINAL=$(echo "$JSON_OUTPUT" | jq -r '[.[] | .images |= join(" ")]')
echo "json=$JSON_OUTPUT_FINAL" >>$GITHUB_OUTPUT
cache:
runs-on: ubuntu-latest
container:
image: ghcr.io/input-output-hk/catalyst-core/ci:latest
defaults:
run:
shell: bash
working-directory: /workspace
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/setup-workspace
- uses: ./.github/actions/setup-earthly
with:
aws_role_arn: ${{ env.AWS_ROLE_ARN }}
aws_region: ${{ env.AWS_REGION }}
- name: Build cache
run: |
earthly \
--buildkit-host "tcp://${{ secrets.EARTHLY_SATELLITE_ADDRESS }}:8372" \
"$(pwd)+builder"
build:
needs: [discover, cache]
runs-on: ubuntu-latest
container:
image: ghcr.io/input-output-hk/catalyst-core/ci:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock
env:
FORCE_COLOR: 1
defaults:
run:
shell: bash
working-directory: /workspace
strategy:
matrix:
target: ${{ fromJson(needs.discover.outputs.json) }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/setup-workspace
- uses: ./.github/actions/setup-earthly
with:
aws_role_arn: ${{ env.AWS_ROLE_ARN }}
aws_region: ${{ env.AWS_REGION }}
- name: Login to ECR
uses: docker/login-action@v2
with:
registry: ${{ env.ECR_REGISTRY }}
- name: Build ${{ matrix.target.path }}+docker
run: |
earthly \
--buildkit-host "tcp://${{ secrets.EARTHLY_SATELLITE_ADDRESS }}:8372" \
${{ matrix.target.path }}+docker
echo "${{ matrix.target.images }}"
# TAG=${{ github.sha }}
# NEW_IMAGE="${{ env.ECR_REGISTRY }}/$IMAGE_NAME:$TAG"
# docker tag "$IMAGE_ID" "$NEW_IMAGE"
# docker push "$NEW_IMAGE"
# echo "${IMAGE_NAME}" > image-name.txt
# - name: Generate timestamp
# id: timestamp
# run: echo "timestamp=$(date +%s%N)" >>$GITHUB_OUTPUT
# - name: Upload artifact
# uses: actions/upload-artifact@v3
# with:
# name: ${{ steps.timestamp.outputs.timestamp }}
# path: /workspace/image-name.txt
# assemble:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Download all artifacts
# uses: actions/download-artifact@v3
# with:
# path: artifacts
# - name: Assemble JSON structure
# run: |
# JSON_CONTENT="{}"
# for file in $(find artifacts -type f -name 'image-name.txt'); do
# IMAGE_NAME=$(cat $file)
# JSON_CONTENT=$(echo $JSON_CONTENT | jq --arg key "$IMAGE_NAME" --arg value "${{ github.sha }}" '. + {($key): $value}')
# done
# echo "$JSON_CONTENT"