-
Notifications
You must be signed in to change notification settings - Fork 48
109 lines (103 loc) · 4.38 KB
/
all-tools.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
name: All tools CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
changes:
runs-on: ubuntu-latest
name: Filter commit changes
outputs:
all-tools: ${{ steps.filter.outputs.all-tools }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Filter commit changes
uses: dorny/paths-filter@v2
id: filter
with:
base: ${{ github.ref }}
list-files: "json"
filters: |
all-tools:
- 'operations/**'
- '.github/workflows/all-tools.yml'
- '.github/workflows/reuse-*.yml'
store_image_name_and_tags:
uses: ./.github/workflows/reuse-store-image-name-and-tags.yml
with:
image_name: consensys/linea-alltools
check_image_tags_exist:
needs: [ changes, store_image_name_and_tags ]
if: ${{ needs.changes.outputs.all-tools == 'false' }}
uses: ./.github/workflows/reuse-check-image-tags-exist.yml
with:
last_commit_tag: ${{ needs.store_image_name_and_tags.outputs.last_commit_tag }}
common_ancestor_tag: ${{ needs.store_image_name_and_tags.outputs.common_ancestor_tag }}
image_name: ${{ needs.store_image_name_and_tags.outputs.image_name }}
secrets: inherit
all-tools-tag-only:
needs: [ changes, store_image_name_and_tags, check_image_tags_exist ]
if: ${{ github.event_name != 'pull_request' && needs.changes.outputs.all-tools == 'false' }}
uses: ./.github/workflows/reuse-image-tag-push.yml
with:
commit_tag: ${{ needs.store_image_name_and_tags.outputs.commit_tag }}
last_commit_tag: ${{ needs.store_image_name_and_tags.outputs.last_commit_tag }}
common_ancestor_tag: ${{ needs.store_image_name_and_tags.outputs.common_ancestor_tag }}
develop_tag: ${{ needs.store_image_name_and_tags.outputs.develop_tag }}
untested_tag_suffix: ${{ needs.store_image_name_and_tags.outputs.untested_tag_suffix }}
image_name: ${{ needs.store_image_name_and_tags.outputs.image_name }}
last_commit_tag_exists: ${{ needs.check_image_tags_exist.outputs.last_commit_tag_exists }}
common_ancestor_commit_tag_exists: ${{ needs.check_image_tags_exist.outputs.common_ancestor_commit_tag_exists }}
secrets: inherit
build-and-publish:
needs: [ changes, store_image_name_and_tags, all-tools-tag-only ]
if: ${{ always() && (needs.changes.outputs.all-tools == 'true' || needs.all-tools-tag-only.result != 'success' || needs.all-tools-tag-only.outputs.image_tagged != 'true') }}
runs-on: ubuntu-22.04
env:
COMMIT_TAG: ${{ needs.store_image_name_and_tags.outputs.commit_tag }}
DEVELOP_TAG: ${{ needs.store_image_name_and_tags.outputs.develop_tag }}
IMAGE_NAME: ${{ needs.store_image_name_and_tags.outputs.image_name }}
name: All tools build and push
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.SELF_GITHUB_SSH_KEY }}
submodules: true
persist-credentials: false
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Note: Building arm* images on QEMU emulator can get extremely slow
# when downloading large packages with npm / yarn. Arm* based docker
# images are not necessarily needed as we run amd64 machines for most
# cases. We can later set up self-hosted arm64 github runners if we
# want arm* based images back.
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# with:
# platforms: 'arm64,arm'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Show the "version" build argument
run: |
echo "We inject the commit tag in the docker image ${{ env.COMMIT_TAG }}"
echo COMMIT_TAG=${{ env.COMMIT_TAG }} >> $GITHUB_ENV
- name: Build and push all tools image
uses: docker/build-push-action@v5
with:
context: .
file: ./operations/Dockerfile
platforms: linux/amd64
# Note: Build amd64 image only
# platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.IMAGE_NAME }}:${{ env.COMMIT_TAG }}