Skip to content

---

--- #464

Workflow file for this run

name: CI
on: [create, pull_request, push]
env:
IMAGE_ID: herve76/node-binance-trader
jobs:
docker:
name: Docker
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2.3.4
- name: Docker Buildx setup
id: buildx
uses: docker/setup-buildx-action@v1.3.0
- name: Registry login
if: github.event_name != 'pull_request'
run: echo "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USER_NAME }}" --password-stdin
- name: Build
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
# Push the Docker image to the registry on git pushes that either pushed a tag or one of the following branches: [master, testing]
if [[
(
"${{ github.event_name }}" == "create"
&&
${{ startsWith(github.ref, 'refs/tags/') }} == "true"
)
||
(
"${{ github.event_name }}" == "push"
&&
${{ startsWith(github.ref, 'refs/heads/') }} == "true"
&&
(
$VERSION == "latest"
||
$VERSION == "testing"
)
)
]]
then
docker buildx build \
--cache-from=$IMAGE_ID:cache \
--cache-to=$IMAGE_ID:cache \
--push \
-t $IMAGE_ID:$VERSION \
.
else
docker buildx build \
--cache-from=$IMAGE_ID:cache \
-t $IMAGE_ID:$VERSION \
.
fi
semantic-release:
if: github.event_name != 'pull_request'
name: Semantic Release
runs-on: ubuntu-latest
needs: docker
steps:
- uses: actions/checkout@v2.3.4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2.5.3
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release-assets:
if: startsWith(github.ref, 'refs/tags/')
name: Release Assets
runs-on: ubuntu-latest
needs: semantic-release
steps:
- name: Git checkout
uses: actions/checkout@v2.3.4
- name: Docker Buildx setup
id: buildx
uses: docker/setup-buildx-action@v1.3.0
- name: Build "build"
run: |
docker buildx build \
--cache-from=$IMAGE_ID:cache \
-t stage_build \
--target build \
--load \
.
docker container create --name extract stage_build
docker container cp extract:/srv/app/ ./
docker container rm -f extract
- name: Zip
uses: montudor/action-zip@v1.0.0
with:
args: zip -qq -r ./nbt.zip ./
- name: GitHub Release Asset
uses: softprops/action-gh-release@v1
with:
files: nbt.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}