mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
339 lines
16 KiB
YAML
339 lines
16 KiB
YAML
name: ocelot.social publish CI
|
|
|
|
on:
|
|
push:
|
|
# branches:
|
|
# - master
|
|
|
|
jobs:
|
|
##############################################################################
|
|
# JOB: PREPARE ###############################################################
|
|
##############################################################################
|
|
prepare:
|
|
name: Prepare
|
|
runs-on: ubuntu-latest
|
|
# needs: [nothing]
|
|
steps:
|
|
##########################################################################
|
|
# CHECKOUT CODE ##########################################################
|
|
##########################################################################
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
##########################################################################
|
|
# TODO: DO STUFF ??? #####################################################
|
|
##########################################################################
|
|
- name: Check translation files
|
|
run: |
|
|
scripts/translations/sort.sh
|
|
scripts/translations/missing-keys.sh
|
|
|
|
##############################################################################
|
|
# JOB: DOCKER BUILD COMMUNITY NEO4J ##########################################
|
|
##############################################################################
|
|
build_production_neo4j:
|
|
name: Docker Build Production - Neo4J
|
|
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
|
|
##########################################################################
|
|
# NEO4J ##################################################################
|
|
##########################################################################
|
|
- name: Neo4J | Build `community` image
|
|
run: |
|
|
docker build \
|
|
--target community \
|
|
-t "ocelotsocialnetwork/neo4j:latest" \
|
|
-t "ocelotsocialnetwork/neo4j:community" \
|
|
-t "ocelotsocialnetwork/neo4j:${VERSION}" \
|
|
-t "ocelotsocialnetwork/neo4j:${BUILD_VERSION}" \
|
|
--build-arg BUILD_DATE=$BUILD_ DATE \
|
|
--build-arg BUILD_VERSION=$BUILD_VERSION \
|
|
--build-arg BUILD_COMMIT=$BUILD_COMMIT \
|
|
neo4j/
|
|
docker save "ocelotsocialnetwork/neo4j" > /tmp/neo4j.tar
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: docker-neo4j-community
|
|
path: /tmp/neo4j.tar
|
|
|
|
##############################################################################
|
|
# JOB: DOCKER BUILD PRODUCTION BACKEND #######################################
|
|
##############################################################################
|
|
build_production_backend:
|
|
name: Docker Build Production - Backend
|
|
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 BACKEND DOCKER IMAGE (production) ################################
|
|
##########################################################################
|
|
- name: backend | Build `production` image
|
|
run: |
|
|
docker build \
|
|
--target production \
|
|
-t "ocelotsocialnetwork/backend:latest" \
|
|
-t "ocelotsocialnetwork/backend:${VERSION}" \
|
|
-t "ocelotsocialnetwork/backend:${BUILD_VERSION}"
|
|
--build-arg BUILD_DATE=$BUILD_ DATE \
|
|
--build-arg BUILD_VERSION=$BUILD_VERSION \
|
|
--build-arg BUILD_COMMIT=$BUILD_COMMIT \
|
|
backend/
|
|
docker save "ocelotsocialnetwork/backend" > /tmp/backend.tar
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: docker-backend-production
|
|
path: /tmp/backend.tar
|
|
|
|
##############################################################################
|
|
# JOB: DOCKER BUILD PRODUCTION WEBAPP ########################################
|
|
##############################################################################
|
|
build_production_webapp:
|
|
name: Docker Build Production - WebApp
|
|
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 WEBAPP DOCKER IMAGE (build) ######################################
|
|
##########################################################################
|
|
- name: webapp | Build `production` image
|
|
run: |
|
|
docker build \
|
|
--target production \
|
|
-t "ocelotsocialnetwork/webapp:latest" \
|
|
-t "ocelotsocialnetwork/webapp:${VERSION}" \
|
|
-t "ocelotsocialnetwork/webapp:${BUILD_VERSION}" \
|
|
--build-arg BUILD_DATE=$BUILD_ DATE \
|
|
--build-arg BUILD_VERSION=$BUILD_VERSION \
|
|
--build-arg BUILD_COMMIT=$BUILD_COMMIT \
|
|
webapp/
|
|
docker save "ocelotsocialnetwork/webapp" > /tmp/webapp.tar
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: docker-webapp-production
|
|
path: /tmp/webapp.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}" \
|
|
--build-arg BUILD_DATE=$BUILD_ DATE \
|
|
--build-arg BUILD_VERSION=$BUILD_VERSION \
|
|
--build-arg BUILD_COMMIT=$BUILD_COMMIT \
|
|
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_production_neo4j,build_production_backend,build_production_webapp,build_production_maintenance]
|
|
# 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 (Neo4J)
|
|
# uses: actions/download-artifact@v2
|
|
# with:
|
|
# name: docker-neo4j-community
|
|
# path: /tmp
|
|
# - name: Load Docker Image
|
|
# run: docker load < /tmp/neo4j.tar
|
|
# - name: Download Docker Image (Backend)
|
|
# uses: actions/download-artifact@v2
|
|
# with:
|
|
# name: docker-backend-production
|
|
# path: /tmp
|
|
# - name: Load Docker Image
|
|
# run: docker load < /tmp/backend.tar
|
|
# - name: Download Docker Image (WebApp)
|
|
# uses: actions/download-artifact@v2
|
|
# with:
|
|
# name: docker-webapp-production
|
|
# path: /tmp
|
|
# - name: Load Docker Image
|
|
# run: docker load < /tmp/webapp.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 neo4j
|
|
# run: docker push --all-tags ocelotsocialnetwork/neo4j
|
|
# - name: Push backend
|
|
# run: docker push --all-tags ocelotsocialnetwork/backend
|
|
# - name: Push webapp
|
|
# run: docker push --all-tags ocelotsocialnetwork/webapp
|
|
# - 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 version tag to GitHub #############################################
|
|
# ##########################################################################
|
|
# # TODO: this will error on duplicate
|
|
# #- name: package-version-to-git-tag
|
|
# # uses: pkgdeps/git-tag-action@v2
|
|
# # with:
|
|
# # github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
# # github_repo: ${{ github.repository }}
|
|
# # version: ${{ env.VERSION }}
|
|
# # git_commit_sha: ${{ github.sha }}
|
|
# # git_tag_prefix: "v"
|
|
# ##########################################################################
|
|
# # 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: yarn install
|
|
# run: yarn install
|
|
# - name: generate changelog
|
|
# run: yarn auto-changelog --latest-version ${{ env.VERSION }} --unreleased-only
|
|
# - 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 |