Update build_docker.yml #8
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker | |
on: | |
push: | |
release: | |
types: [published] | |
permissions: | |
contents: read | |
jobs: | |
build_and_push_docker: | |
permissions: | |
packages: write | |
contents: none | |
name: Build and Push Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.PIPELINE_TOKEN }} | |
submodules: true | |
- name: Prepare | |
id: prep | |
run: | | |
TAG=$(echo $(git describe ${{ github.sha }} --tags)) | |
VALID_TAG="^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" | |
DOCKER_IMAGE=chatbotbp/botpress_brasil_participativo | |
VERSION=() | |
TAGS=() | |
if [[ $TAG =~ $VALID_TAG ]]; then | |
VERSION+=($(echo ${TAG} | sed -r 's/v//')) | |
VERSION+=('latest') | |
VERSION+=($(echo ${TAG} | sed -r 's/\./_/g')) | |
TAGS+=("${VERSION[@]/#/${DOCKER_IMAGE}:}") | |
echo "release=true" >> $GITHUB_ENV | |
elif [[ $GITHUB_REF == refs/heads/* ]]; then | |
VERSION+=($(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')) | |
fi | |
GITHUB_REGISTRY="ghcr.io/residenciaticbrisa/t2g2-chatbot-botpress" | |
TAGS+=("${VERSION[@]/#/${GITHUB_REGISTRY}:}") | |
IFS=, | |
echo "version=${VERSION[*]}" >> $GITHUB_ENV | |
echo "tags=${TAGS[*]}" >> $GITHUB_ENV | |
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'yarn' | |
- name: Build | |
run: | | |
export npm_config_target_platform=linux | |
export EDITION=pro | |
git submodule update --init | |
yarn --force --ignore-engines --frozen-lockfile | |
yarn run build --linux --prod --verbose | |
yarn run package --linux | |
cp build/docker/Dockerfile packages/bp/binaries/ | |
- name: DockerHub Authentication | |
if: env.release == 'true' | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.PIPELINE_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./packages/bp/binaries | |
push: true | |
tags: ${{ env.tags }} | |
labels: | | |
org.opencontainers.image.source=${{ github.event.repository.html_url }} | |
org.opencontainers.image.created=${{ env.created }} | |
org.opencontainers.image.revision=${{ github.sha }} |