ci: init (#5)

* feat: build docker images with one script

* feat: publish the built docker image

* ci: init worflow to publish built docker image

* chore: add the new commands to the package.json

* ci: add npm setup command run

* ci: build with only node 12.x

* refactor: add github repo bee image prefix to .env

* ci: github action input for build docker image

* fix: intend in yaml

* fix: typeo

* fix: testing the rumor about github bug in order to show up the run workflow button

* revert: prev commit - did not work

* ci: only build image if it was clicked manually
This commit is contained in:
nugaon 2021-05-04 14:48:36 +02:00 committed by GitHub
parent 9d9afbfe25
commit 1b66139c7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 68 additions and 3 deletions

43
.github/workflows/publish.yaml vendored Normal file
View File

@ -0,0 +1,43 @@
on:
workflow_dispatch:
inputs:
buildImage:
description: 'Build Docker Image according to the environment'
default: 'false'
push:
branches:
- 'master'
pull_request:
branches:
- '**'
env:
BEE_IMAGE_PREFIX: 'docker.pkg.github.com/ethersphere/bee-factory'
jobs:
bee-images:
name: Build and publish images
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Auth to Github Package Docker Registry
if: (github.ref == 'refs/heads/master' || ${{ github.event.inputs.buildImage }} == 'true') && success()
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin
- name: Install npm deps
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
- name: Build images
run: |
npm run build:env
- name: Publish if it was clicked manually
if: ${{ github.event.inputs.buildImage }} == 'true' && success()
run: |
npm run publish:env

View File

@ -5,8 +5,10 @@
"scripts": {
"compile:chequebook": "truffle compile",
"migrate:chequebook": "truffle migrate",
"test:chequebook": "truffle test",
"supply": "truffle exec src/supply.js"
"supply": "truffle exec src/supply.js",
"build:env": "./scripts/build-environment.sh",
"publish:env": "./scripts/publish-environment.sh",
"run:env": "./scripts/environment.sh"
},
"dependencies": {
"@openzeppelin/contracts": "^3.1.0",

View File

@ -1,4 +1,4 @@
BEE_VERSION="0.5.3"
BLOCKCHAIN_VERSION="1.0.0"
BEE_ENV_PREFIX="swarm-test"
BEE_IMAGE_PREFIX=ethersphere
BEE_IMAGE_PREFIX="docker.pkg.github.com/ethersphere/bee-factory"

10
scripts/build-environment.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
MY_PATH=$(dirname "$0")
MY_PATH=$( cd "$MY_PATH" && pwd )
"$MY_PATH/network.sh"
"$MY_PATH/blockchain.sh"
npm run migrate:chequebook
npm run supply
"$MY_PATH/blockchain-docker-build.sh"
"$MY_PATH/bee-docker-build.sh"

10
scripts/publish-environment.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
MY_PATH=$(dirname "$0")
MY_PATH=$( cd "$MY_PATH" && pwd )
DOCKER_IMAGES=$(docker image ls -qaf reference="$BEE_IMAGE_PREFIX/$BEE_ENV_PREFIX*:$BEE_VERSION")
for DOCKER_IMAGE in $DOCKER_IMAGES
do
echo "$DOCKER_IMAGE"
docker push "$DOCKER_IMAGE"
done