ci: build images on bee release (#57)

Co-authored-by: nugaon <50576770+nugaon@users.noreply.github.com>
This commit is contained in:
Adam Uhlíř 2021-11-12 10:31:32 +01:00 committed by GitHub
parent 7fb69c9b3f
commit ef353732ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,6 @@
on: on:
repository_dispatch:
types: [ build-images ]
workflow_dispatch: workflow_dispatch:
inputs: inputs:
buildImage: buildImage:
@ -25,10 +27,10 @@ on:
env: env:
BEE_IMAGE_PREFIX: 'docker.pkg.github.com/ethersphere/bee-factory' BEE_IMAGE_PREFIX: 'docker.pkg.github.com/ethersphere/bee-factory'
COMMIT_VERSION_TAG: ${{ github.event.inputs.commitVersionTag }} BUILD_IMAGE: 'true'
BEE_VERSION: ${{ github.event.inputs.beeVersion }} COMMIT_VERSION_TAG: 'true'
BUILD_IMAGE: ${{ github.event.inputs.beeVersionAsCommitHash }} STATE_COMMIT: 'true'
STATE_COMMIT: ${{ github.event.inputs.stateCommit }} BEE_VERSION: '${{ github.event.client_payload.tag }}'
jobs: jobs:
bee-images: bee-images:
@ -37,19 +39,29 @@ jobs:
steps: steps:
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
with: with:
node-version: 15 node-version: 16
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with:
fetch-depth: 1 - 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
fi
- name: Auth to Github Package Docker Registry - name: Auth to Github Package Docker Registry
if: ${{ github.event.inputs.buildImage == 'true' && success() }} if: ${{ github.event_name == 'repository_dispatch' || (github.event.inputs.buildImage == 'true' && success()) }}
run: | run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin
- name: Install npm deps - name: Install npm deps
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci run: npm ci
- name: Build images - name: Build images
run: | run: |
BUILD_PARAMS="" BUILD_PARAMS=""
@ -60,7 +72,8 @@ jobs:
BUILD_PARAMS+=" --gen-traffic" BUILD_PARAMS+=" --gen-traffic"
fi fi
npm run build:env -- $BUILD_PARAMS npm run build:env -- $BUILD_PARAMS
- name: Publish if it was clicked manually
if: ${{ github.event.inputs.buildImage == 'true' && success() }} - name: Publish if required
if: ${{ github.event_name == 'repository_dispatch' || (github.event.inputs.buildImage == 'true' && success()) }}
run: | run: |
npm run publish:env npm run publish:env