-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (123 loc) · 5.46 KB
/
builder.yml
File metadata and controls
127 lines (123 loc) · 5.46 KB
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
name: builder
on:
push:
workflow_dispatch:
jobs:
generator:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
buildx: ${{ steps.generate-buildx.outputs.buildx }}
tags: ${{ steps.generate-tags.outputs.tags }}
test-images: ${{ steps.generate-test-images.outputs.test-images }}
steps:
- uses: actions/checkout@v3
- name: Fetch Dependencies
run: sudo apt install -qq -y jq
- name: Export Build Matrix
id: generate-matrix
run: echo "matrix=$(jq -rc '.matrix' manifest.json)" >> ${GITHUB_OUTPUT}
- name: Export docker build/buildx tags
id: generate-buildx
run: echo "buildx=$(jq -rc '.buildx' manifest.json)" >> ${GITHUB_OUTPUT}
- name: Export tag list
id: generate-tags
run: echo "tags=$(jq -rc '.tags' manifest.json)" >> ${GITHUB_OUTPUT}
- name: Export testing image names/tags
id: generate-test-images
run: echo "test-images=$(jq -rc '."test-images"' manifest.json)" >> ${GITHUB_OUTPUT}
image-builder:
needs: generator
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJSON(needs.generator.outputs.matrix) }}
fail-fast: false
steps:
- name: Set up QEMU
if: github.ref == 'refs/heads/master'
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
if: github.ref == 'refs/heads/master'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_TOKEN }}
password: ${{ secrets.DOCKER_HUB_SECRET }}
- uses: actions/checkout@v3
- name: Fetch Dependencies
run: sudo apt install -qq -y jq moreutils
- name: Build local testing Image
run: |
IMAGE="$(echo '${{needs.generator.outputs.test-images}}' | jq -r '."${{matrix.image}}"."${{matrix.nodegit}}"')" &&
docker buildx build --load --build-arg ALPINE_TAG=${{matrix.image}} --build-arg NODEGIT_VERSION=${{matrix.nodegit}} --tag ${IMAGE} .
- name: Check Nodegit Version
run: |
IMAGE="$(echo '${{needs.generator.outputs.test-images}}' | jq -r '."${{matrix.image}}"."${{matrix.nodegit}}"')" &&
NODEGIT="$(docker run --rm $IMAGE /usr/local/bin/npm -g ls nodegit --json | jq -r '.dependencies.nodegit.version')" && echo "nodegit versions: ${NODEGIT}"
[ "$NODEGIT" == "${{matrix.nodegit}}" ] &&
echo "nodegit versions @${{matrix.nodegit}} [ OK ]"
- name: Test Nodegit
run: |
IMAGE="$(echo '${{needs.generator.outputs.test-images}}' | jq -r '."${{matrix.image}}"."${{matrix.nodegit}}"')" &&
docker run --rm -v "$(pwd)/test":/test $IMAGE /bin/ash -c "cp -r /test ~/test && cd ~/test && chmod +x init.sh && ./init.sh && echo using: && cat package.json && npm install && node test.js"
- name: Build and push multiarch Images
if: github.ref == 'refs/heads/master'
run: docker buildx build --push --build-arg ALPINE_TAG=${{matrix.image}} --build-arg NODEGIT_VERSION=${{matrix.nodegit}} --platform "linux/amd64,linux/arm64" $(echo '${{needs.generator.outputs.buildx}}' | jq -r '."${{matrix.image}}"."${{matrix.nodegit}}"') .
- name: Prepare status artifact [${{matrix.image}}@${{matrix.nodegit}}.json]
if: ${{ always() }}
run: |
mkdir status &&
echo '{}' | jq --arg run "${GITHUB_RUN_ID}" --arg image "${{matrix.image}}" --arg nodegit "${{matrix.nodegit}}" '. + {run: $run, image: $image, nodegit: $nodegit}' > status/${{matrix.image}}@${{matrix.nodegit}}.json
- name: Finalize status artifact @success
if: ${{ success() }}
run: |
cat status/${{matrix.image}}@${{matrix.nodegit}}.json | jq --argjson success true '. + {success: $success}' | sponge status/${{matrix.image}}@${{matrix.nodegit}}.json
- name: Finalize status artifact @failure
if: ${{ failure() }}
run: |
cat status/${{matrix.image}}@${{matrix.nodegit}}.json | jq --argjson success false '. + {success: $success}' | sponge status/${{matrix.image}}@${{matrix.nodegit}}.json
- name: Upload status artifact [${{matrix.image}}@${{matrix.nodegit}}.json]
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v3
with:
name: status
path: status/
report:
needs:
- generator
- image-builder
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
check-latest: true
- name: Fetch Dependencies
run: sudo apt install -qq -y jq && npm install
- name: Fetch matrix jobs status artifacts
uses: actions/download-artifact@v3
with:
path: jobs
- name: Initialize report [jobs/tags.json]
run: echo '${{needs.generator.outputs.tags}}' | jq '.' > jobs/tags.json
- name: Generate Docker Hub Readme [HUB.md]
run: node report >> HUB.md
- name: Upload HUB.md
uses: actions/upload-artifact@v3
with:
name: HUB.md
path: HUB.md
- name: push README to Dockerhub
if: github.ref == 'refs/heads/master'
uses: christian-korneck/update-container-description-action@v1
env:
DOCKER_USER: ${{ secrets.DOCKER_HUB_TOKEN }}
DOCKER_PASS: ${{ secrets.DOCKER_HUB_SECRET_RM }}
with:
destination_container_repo: bitmeal/nodegit
provider: dockerhub
short_description: ✨ a node:alpine based image, shipping precompiled nodegit versions 🚢
readme_file: HUB.md