Skip to content

feature/ad-engine/draft/3 #5

feature/ad-engine/draft/3

feature/ad-engine/draft/3 #5

Workflow file for this run

# ╭──────────────────────────────────────────────────────────────────╮
# │ 🐙 GITHUB ACIONS CI/CD WORKFLOW │
# ┣──────────────────────────────────────────────────────────────────┫
# │ Responsible for: │
# │ ➤ [1] 'auto-bump' & 'tag' project version. │
# │ ➤ [2] auto-create release + tag of project. │
# │ ➤ [3] [disabled] sentry JS sourcemap upload │
# │ ➤ [4] build & publish docker image │
# │ ➤ [5] [disabled] auto-deploy project to target server. │
# ╰──────────────────────────────────────────────────────────────────╯
name: '⚡️ Bump ➤ Publish ➤ Release'
'on':
pull_request:
types:
- closed
branches:
- main
jobs:
# ╭──────────────────────────────────────────────────────────────────╮
# │ NOTE: │
# │ ➤ [1] 'auto-bump' & 'tag' project version. │
# ╰──────────────────────────────────────────────────────────────────╯
npm-version-bump:
name: NPM Version Bump
if: github.event.pull_request.merged == true
runs-on: ubuntu-22.04
# ▓ NOTE:
# ▓ > map a step output to a job output.
# ▓ > 🔗 read-more /:/ https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs
outputs:
output1: ${{ steps.step1.outputs.bump_version_bool }}
output2: ${{ steps.set-version.outputs.release_tag }}
steps:
- name: "STEP /:/ checkout source code"
uses: actions/checkout@v4
with:
token: '${{ secrets.GH_TOKEN }}'
fetch-depth: 0
fetch-tags: true
ref: main
- name: "STEP /:/ git config"
run: |
git config --local user.email "${{ secrets.GH_ORG_EMAIL }}"
git config --local user.name "${{ secrets.GH_ORG_NAME }}"
- name: "STEP /:/ node config"
uses: actions/setup-node@v3
with:
node-version: 18.19.0
- name: "STEP /:/ npm config"
run: |
npm install -g npm@10.2.3
- name: "STEP /:/ check semver:patch"
if: contains(github.event.pull_request.labels.*.name, 'semver:patch')
run: |
npm version patch
- name: "STEP /:/ check semver:minor"
if: contains(github.event.pull_request.labels.*.name, 'semver:minor')
run: |
npm version minor
- name: "STEP /:/ check semver:major"
if: contains(github.event.pull_request.labels.*.name, 'semver:major')
run: |
npm version major
- name: "STEP /:/ check version bump"
id: step1
if: ${{
contains(github.event.pull_request.labels.*.name, 'semver:patch')
|| contains(github.event.pull_request.labels.*.name, 'semver:minor')
|| contains(github.event.pull_request.labels.*.name, 'semver:major')
}}
# ▓ > 🔗 read-more /:/ https://michaelcurrin.github.io/dev-cheatsheets/cheatsheets/ci-cd/github-actions/persist.html
# ▓ > 🔗 read-more /:/ https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
run: |
echo "bump_version_bool=true" >> "$GITHUB_OUTPUT"
- name: "STEP /:/ persist version bump"
run: |
git push origin main --follow-tags --force
- name: "STEP /:/ set new version"
id: set-version
run: |
npm pkg get version
echo "release_tag=$(npm pkg get version --workspaces=false | tr -d \") ">> $GITHUB_OUTPUT
- name: "STEP /:/ check output/set version"
env:
RELEASE_VERSION: ${{ steps.set-version.outputs.release_tag }}
run: |
echo $RELEASE_VERSION
echo ${{ steps.set-version.outputs.release_tag }}
#
# ╭──────────────────────────────────────────────────────────────────╮
# │ NOTE: │
# │ ➤ [2] auto-create release + tag of project. │
# ╰──────────────────────────────────────────────────────────────────╯
create-release:
name: Git Create Release
needs: npm-version-bump
if: needs.npm-version-bump.outputs.output1 == 'true'
# (alternative) [#1]
env:
RELEASE_TAG: ${{ needs.npm-version-bump.outputs.output2 }}
runs-on: ubuntu-22.04
steps:
- uses: "marvinpinto/action-automatic-releases@latest"
# SEE:
# https://github.com/marketplace/actions/automatic-releases
with:
automatic_release_tag: "v${{ env.RELEASE_TAG }}"
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
#
# ╭──────────────────────────────────────────────────────────────────╮
# │ NOTE: │
# │ ➤ [3] [disabled] sentry JS sourcemap upload │
# ╰──────────────────────────────────────────────────────────────────╯
sentry-sourcemap-deploy:
name: 🟣 Sentry sourcemap (artifacts) upload
needs: create-release
if: false
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
ref: main
- uses: actions/setup-node@v3
with:
node-version: 18.19.0
- name: 'setup npm'
run: |
npm install -g npm@10.2.3
- name: 'build'
env:
NODE_OPTIONS: "--max-old-space-size=8192"
run: |
npm install
npm run build-2
#
# ╭──────────────────────────────────────────────────────────────────╮
# │ NOTE: │
# │ ➤ [4] build & publish docker image │
# ╰──────────────────────────────────────────────────────────────────╯
docker-image-build-and-push:
name: 🐳 JOB /:/ Docker Image Build & Publish
runs-on: ubuntu-22.04
needs: create-release
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: "STEP /:/ build docker image"
run: |
make docker-image-build
# [🐞]
docker images
# [🐞]
docker images betarena-scores --format "{{.ID}}" --no-trunc --filter "label=project=Scores"
echo "ENV_IMAGE_TAG_ID=$(docker images betarena-scores --format "{{.ID}}" --no-trunc --filter "label=project=Scores")" >> $GITHUB_ENV
- name: "STEP /:/ publish docker image"
run: |
make docker-image-publish-to-registry
env:
ENV_IMAGE_TAG_ID: ${{ env.ENV_IMAGE_TAG_ID }}
ENV_DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
#
# ╭──────────────────────────────────────────────────────────────────╮
# │ NOTE: │
# │ ➤ [5] [disabled] auto-deploy project to target server. │
# ╰──────────────────────────────────────────────────────────────────╯
deploy:
name: 🚀 JOB /:/ Deployment
if: false
needs: docker-image-build-and-push
runs-on: ubuntu-22.04
steps:
- uses: appleboy/ssh-action@v0.1.7
with:
host: ${{secrets.SERVER_HOST}}
key: ${{secrets.SERVER_KEY}}
script: |
# [ℹ] Navigate to target project directory
cd web/scores
# [ℹ] Update the directory with latests changes
git stash
git pull origin main
# [ℹ] Run target makefile command
make docker-spin-start-production
#
#