This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
135 lines (121 loc) · 4.96 KB
/
publish.yaml
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
on:
repository_dispatch:
types: [ build-images ]
workflow_dispatch:
inputs:
buildImage:
description: 'Build and push Docker Image according to the environment'
default: 'false'
commitVersionTag:
description: 'The image tag will be retrieved from the bee version command'
default: 'false'
beeVersion:
description: 'The official bee image tag that the image will be built on. Default: last supported version'
default: 'latest'
beeVersionAsCommitHash:
description: 'The beeVersion parameter will be interpreted as a source code commit hash that the bee base image will be built on'
default: 'false'
stateCommit:
description: 'The images will have cheques by the traffic generation'
default: 'false'
branch:
description: 'Branch of this repo to build (default "master")'
default: master
required: false
push:
branches:
- 'master'
pull_request:
branches:
- '**'
env:
BEE_IMAGE_PREFIX: 'ethersphere'
BUILD_IMAGE: 'false'
COMMIT_VERSION_TAG: 'false'
STATE_COMMIT: 'true'
BEE_VERSION: '${{ github.event.client_payload.tag }}'
BEE_PLATFORM: 'linux/amd64,linux/arm64,linux/arm/v7'
jobs:
bee-images:
name: Build and publish images
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Override inputs from `workflow_dispatch`
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "BEE_VERSION=${{ github.event.inputs.beeVersion }}" >> $GITHUB_ENV
echo "BUILD_IMAGE=${{ github.event.inputs.beeVersionAsCommitHash }}" >> $GITHUB_ENV
echo "COMMIT_VERSION_TAG=${{ github.event.inputs.commitVersionTag }}" >> $GITHUB_ENV
echo "STATE_COMMIT=${{ github.event.inputs.stateCommit }}" >> $GITHUB_ENV
else
echo "BEE_VERSION=${BEE_VERSION/v}" >> $GITHUB_ENV
fi
- name: Auth to Docker Hub
if: ${{ github.event_name == 'repository_dispatch' || (github.event.inputs.buildImage == 'true' && success()) }}
run: |
echo "PUSH_IMAGES=1" >> $GITHUB_ENV
echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u ${{secrets.DOCKERHUB_USERNAME}} --password-stdin
- uses: actions/cache@v3
id: cache-npm
with:
path: generator/node_modules
key: ${{ runner.os }}-${{ hashFiles('generator/package-lock.json') }}
- name: Install npm deps
if: steps.cache-npm.outputs.cache-hit != 'true'
run: cd ./generator && npm ci
- name: Build images
id: build
run: |
cd ./generator
BUILD_PARAMS=""
if [ $BUILD_IMAGE == 'true' ] ; then
BUILD_PARAMS+=" --build-base-bee --base-bee-commit-hash=$BEE_VERSION"
fi
if [ $STATE_COMMIT == 'true' ] ; then
BUILD_PARAMS+=" --gen-traffic"
fi
npm run build:env -- $BUILD_PARAMS
- name: Update bee version in package.json
uses: jossef/action-set-json-field@v2
if: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.tag != 'latest' }}
with:
file: package.json
field: engines.bee
value: ${{ env.BEE_VERSION }}
- name: Add trailing new-line to package.json
if: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.tag != 'latest' }}
run: printf "\n" >> package.json
- name: Create/update PR
if: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.tag != 'latest' }}
uses: gr2m/create-or-update-pull-request-action@v1
env:
GITHUB_TOKEN: ${{ secrets.REPO_GHA_PAT }}
with:
title: "chore: update to bee ${{ env.BEE_VERSION }}"
body: "Updated Bee version ${{ env.BEE_VERSION }}"
branch: "bee-${{ env.BEE_VERSION }}"
commit-message: "chore: update to new bee"
author: "bee-worker <[email protected]>"
- name: Trigger Bee-js PR creation
if: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.tag != 'latest' }}
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.REPO_GHA_PAT }}
repository: ethersphere/bee-js
event-type: update-bee
client-payload: '{"beeVersion": "${{ steps.build.outputs.full-version }}", "apiVersion": "${{ steps.build.outputs.api-version }}", "debugApiVersion": "${{ steps.build.outputs.debug-api-version }}"}'