publish workflow
This commit is contained in:
parent
d049729b25
commit
f7b0c44939
285
.github/workflows/publish.yml
vendored
Normal file
285
.github/workflows/publish.yml
vendored
Normal file
@ -0,0 +1,285 @@
|
||||
#name: CD
|
||||
#
|
||||
#on:
|
||||
# push:
|
||||
# branches: [ master ]
|
||||
#
|
||||
#jobs:
|
||||
# build:
|
||||
# name: Build and push docker images
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - name: Checkout code
|
||||
# uses: actions/checkout@v2
|
||||
# with:
|
||||
# submodules: recursive
|
||||
#
|
||||
# - name: Build neo4j image
|
||||
# uses: docker/build-push-action@v1.1.0
|
||||
# with:
|
||||
# repository: ocelotsocialnetwork/develop-neo4j
|
||||
# username: ${{ secrets.DOCKER_USERNAME }}
|
||||
# password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
# tags: latest
|
||||
# path: Ocelot-Social/neo4j/
|
||||
# - name: Build backend base image
|
||||
# uses: docker/build-push-action@v1.1.0
|
||||
# with:
|
||||
# repository: ocelotsocialnetwork/develop-backend
|
||||
# username: ${{ secrets.DOCKER_USERNAME }}
|
||||
# password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
# tags: build-and-test
|
||||
# target: build-and-test
|
||||
# path: Ocelot-Social/backend/
|
||||
# - name: Build webapp base image
|
||||
# uses: docker/build-push-action@v1.1.0
|
||||
# with:
|
||||
# repository: ocelotsocialnetwork/develop-webapp
|
||||
# username: ${{ secrets.DOCKER_USERNAME }}
|
||||
# password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
# tags: build-and-test
|
||||
# target: build-and-test
|
||||
# path: Ocelot-Social/webapp/
|
||||
#
|
||||
# - name: Build backend customized image
|
||||
# uses: docker/build-push-action@v1.1.0
|
||||
# with:
|
||||
# repository: ocelotsocialnetwork/develop-backend
|
||||
# username: ${{ secrets.DOCKER_USERNAME }}
|
||||
# password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
# tags: latest
|
||||
# path: backend/
|
||||
# - name: Build webapp customized image
|
||||
# uses: docker/build-push-action@v1.1.0
|
||||
# with:
|
||||
# repository: ocelotsocialnetwork/develop-webapp
|
||||
# username: ${{ secrets.DOCKER_USERNAME }}
|
||||
# password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
# tags: latest
|
||||
# path: webapp/
|
||||
|
||||
|
||||
name: ocelot.social publish branded CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
##############################################################################
|
||||
# JOB: DOCKER BUILD BRANDED BACKEND ##########################################
|
||||
##############################################################################
|
||||
build_branded_backend:
|
||||
name: Docker Build Branded - Backend
|
||||
runs-on: ubuntu-latest
|
||||
#needs: [nothing]
|
||||
steps:
|
||||
##########################################################################
|
||||
# CHECKOUT CODE ##########################################################
|
||||
##########################################################################
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
##########################################################################
|
||||
# SET ENVS ###############################################################
|
||||
##########################################################################
|
||||
- name: ENV - VERSION
|
||||
run: echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
|
||||
- name: ENV - BUILD_DATE
|
||||
run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
|
||||
- name: ENV - BUILD_VERSION
|
||||
run: echo "BUILD_VERSION=${VERSION}.${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
|
||||
- name: ENV - BUILD_COMMIT
|
||||
run: echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV
|
||||
##########################################################################
|
||||
# BUILD BACKEND DOCKER IMAGE (branded) ################################
|
||||
##########################################################################
|
||||
- name: backend | Build `branded` image
|
||||
run: |
|
||||
docker build --target branded -t "ocelotsocialnetwork/backend-branded:latest" -t "ocelotsocialnetwork/backend-branded:${VERSION}" -t "ocelotsocialnetwork/backend-branded:${BUILD_VERSION}" -f backend.Dockerfile .
|
||||
docker save "ocelotsocialnetwork/backend-branded" > /tmp/backend-branded.tar
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: docker-backend-branded
|
||||
path: /tmp/backend-branded.tar
|
||||
|
||||
##############################################################################
|
||||
# JOB: DOCKER BUILD BRANDED WEBAPP ###########################################
|
||||
##############################################################################
|
||||
build_branded_webapp:
|
||||
name: Docker Build Branded - WebApp
|
||||
runs-on: ubuntu-latest
|
||||
#needs: [nothing]
|
||||
steps:
|
||||
##########################################################################
|
||||
# CHECKOUT CODE ##########################################################
|
||||
##########################################################################
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
##########################################################################
|
||||
# SET ENVS ###############################################################
|
||||
##########################################################################
|
||||
- name: ENV - VERSION
|
||||
run: echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
|
||||
- name: ENV - BUILD_DATE
|
||||
run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
|
||||
- name: ENV - BUILD_VERSION
|
||||
run: echo "BUILD_VERSION=${VERSION}.${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
|
||||
- name: ENV - BUILD_COMMIT
|
||||
run: echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV
|
||||
##########################################################################
|
||||
# BUILD WEBAPP DOCKER IMAGE (build) ######################################
|
||||
##########################################################################
|
||||
- name: webapp | Build `branded` image
|
||||
run: |
|
||||
docker build --target branded -t "ocelotsocialnetwork/webapp-branded:latest" -t "ocelotsocialnetwork/webapp-branded:${VERSION}" -t "ocelotsocialnetwork/webapp-branded:${BUILD_VERSION}" -f webapp.Dockerfile .
|
||||
docker save "ocelotsocialnetwork/webapp-branded" > /tmp/webapp-branded.tar
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: docker-webapp-branded
|
||||
path: /tmp/webapp-branded.tar
|
||||
|
||||
##############################################################################
|
||||
# JOB: DOCKER BUILD PRODUCTION MAINTENANCE ###################################
|
||||
###############################################################################
|
||||
#build_production_maintenance:
|
||||
# name: Docker Build Production - Maintenance
|
||||
# runs-on: ubuntu-latest
|
||||
# needs: [prepare]
|
||||
# steps:
|
||||
# ##########################################################################
|
||||
# # CHECKOUT CODE ##########################################################
|
||||
# ##########################################################################
|
||||
# - name: Checkout code
|
||||
# uses: actions/checkout@v2
|
||||
# ##########################################################################
|
||||
# # SET ENVS ###############################################################
|
||||
# ##########################################################################
|
||||
# - name: ENV - VERSION
|
||||
# run: echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
|
||||
# - name: ENV - BUILD_DATE
|
||||
# run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
|
||||
# - name: ENV - BUILD_VERSION
|
||||
# run: echo "BUILD_VERSION=${VERSION}.${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
|
||||
# - name: ENV - BUILD_COMMIT
|
||||
# run: echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV
|
||||
# ##########################################################################
|
||||
# # BUILD MAINTENANCE DOCKER IMAGE (build) #################################
|
||||
# ##########################################################################
|
||||
# - name: maintenance | Build `production` image
|
||||
# # TODO: --target production
|
||||
# run: |
|
||||
# docker build -t "ocelotsocialnetwork/maintenance:latest" -t "ocelotsocialnetwork/maintenance:${VERSION}" -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}" webapp/ -f webapp/Dockerfile.maintenance
|
||||
# docker save "ocelotsocialnetwork/maintenance" > /tmp/maintenance.tar
|
||||
# - name: Upload Artifact
|
||||
# uses: actions/upload-artifact@v2
|
||||
# with:
|
||||
# name: docker-maintenance-production
|
||||
# path: /tmp/maintenance.tar
|
||||
|
||||
##############################################################################
|
||||
# JOB: UPLOAD TO DOCKERHUB ###################################################
|
||||
##############################################################################
|
||||
upload_to_dockerhub:
|
||||
name: Upload to Dockerhub
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build_branded_backend,build_branded_webapp]
|
||||
env:
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
steps:
|
||||
##########################################################################
|
||||
# CHECKOUT CODE ##########################################################
|
||||
##########################################################################
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
##########################################################################
|
||||
# DOWNLOAD DOCKER IMAGES #################################################
|
||||
##########################################################################
|
||||
- name: Download Docker Image (Backend)
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: docker-backend-branded
|
||||
path: /tmp
|
||||
- name: Load Docker Image
|
||||
run: docker load < /tmp/backend-branded.tar
|
||||
- name: Download Docker Image (WebApp)
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: docker-webapp-branded
|
||||
path: /tmp
|
||||
- name: Load Docker Image
|
||||
run: docker load < /tmp/webapp-branded.tar
|
||||
#- name: Download Docker Image (Maintenance)
|
||||
# uses: actions/download-artifact@v2
|
||||
# with:
|
||||
# name: docker-maintenance-production
|
||||
# path: /tmp
|
||||
#- name: Load Docker Image
|
||||
# run: docker load < /tmp/maintenance.tar
|
||||
##########################################################################
|
||||
# Upload #################################################################
|
||||
##########################################################################
|
||||
- name: login to dockerhub
|
||||
run: echo "${DOCKERHUB_TOKEN}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
|
||||
- name: Push backend
|
||||
run: docker push --all-tags ocelotsocialnetwork/backend-branded
|
||||
- name: Push webapp
|
||||
run: docker push --all-tags ocelotsocialnetwork/webapp-branded
|
||||
#- name: Push maintenance
|
||||
# run: docker push --all-tags ocelotsocialnetwork/maintenance
|
||||
|
||||
##############################################################################
|
||||
# JOB: GITHUB TAG LATEST VERSION #############################################
|
||||
##############################################################################
|
||||
github_tag:
|
||||
name: Tag latest version on Github
|
||||
runs-on: ubuntu-latest
|
||||
needs: [upload_to_dockerhub]
|
||||
steps:
|
||||
##########################################################################
|
||||
# CHECKOUT CODE ##########################################################
|
||||
##########################################################################
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0 # Fetch full History for changelog
|
||||
##########################################################################
|
||||
# SET ENVS ###############################################################
|
||||
##########################################################################
|
||||
- name: ENV - VERSION
|
||||
run: echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
|
||||
- name: ENV - BUILD_DATE
|
||||
run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
|
||||
- name: ENV - BUILD_VERSION
|
||||
run: echo "BUILD_VERSION=${VERSION}.${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
|
||||
- name: ENV - BUILD_COMMIT
|
||||
run: echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV
|
||||
##########################################################################
|
||||
# Push build tag to GitHub ###############################################
|
||||
##########################################################################
|
||||
- name: package-version-to-git-tag + build number
|
||||
uses: pkgdeps/git-tag-action@v2
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
github_repo: ${{ github.repository }}
|
||||
version: ${{ env.BUILD_VERSION }}
|
||||
git_commit_sha: ${{ github.sha }}
|
||||
git_tag_prefix: "b"
|
||||
##########################################################################
|
||||
# Push release tag to GitHub #############################################
|
||||
##########################################################################
|
||||
- name: package-version-to-git-release
|
||||
continue-on-error: true # Will fail if tag exists
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
|
||||
with:
|
||||
tag_name: ${{ env.VERSION }}
|
||||
release_name: ${{ env.VERSION }}
|
||||
#body_path: ./CHANGELOG.md
|
||||
draft: false
|
||||
prerelease: false
|
||||
Loading…
x
Reference in New Issue
Block a user