Skip to content

fix: release version bump #13

fix: release version bump

fix: release version bump #13

Workflow file for this run

name: Semantic release
on:
push:
branches: [ prod, staging ]
env:
NODE_VERSION: 18.13.0
APP_BUILD_ARGS: --unlock-robots
APP_BUILD_PATH: ./build
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/web
DOCKER_FILE: node_modules/@lomray/vite-ssr-boost/workflow/Dockerfile
ECS_TASK_DEFINITION: .github/task-definition.json
ECS_TASK_CONTAINER_NAME: web
ECS_SERVICE: vite-template
ECS_CLUSTER: Development
jobs:
build:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref }}-build
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
- run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run eslint
run: npm run lint:check
- name: Typescript check
run: npm run ts:check
- name: Stylelint check
run: npm run style:check
- name: Build application
run: |
npm pkg delete scripts.prepare
npm run build -- ${{ env.APP_BUILD_ARGS }}
- name: Create release asset
run: zip -r build.zip build package.json package-lock.json README.md
- name: Archive build
uses: actions/upload-artifact@v3
with:
name: build-artifact
path: |
build
package.json
package-lock.json
build.zip
- name: Archive dockerfile
uses: actions/upload-artifact@v3
with:
name: dockerfile-artifact
path: ${{ env.DOCKER_FILE }}
- name: Archive AWS task definition
uses: actions/upload-artifact@v3
with:
name: aws-task-definition-artifact
path: ${{ env.ECS_TASK_DEFINITION }}
release:
needs: [build]
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref }}-release
cancel-in-progress: true
outputs:
version: ${{ steps.package-version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build-artifact
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
- name: Get version
id: package-version
run: npx @lomray/microservices-cli package-version
docker-build:
needs: [build, release]
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref }}-build-docker
cancel-in-progress: true
outputs:
# get docker image tag with version
image-tag: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
steps:
- uses: actions/download-artifact@v3
with:
name: build-artifact
- uses: actions/download-artifact@v3
with:
name: dockerfile-artifact
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
- name: Log into registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,prefix={{branch}}-,value=${{ needs.release.outputs.version }}
type=raw,prefix=latest-,value={{branch}}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_PATH=${{ env.APP_BUILD_PATH }}
deploy:
needs: [ docker-build ]
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref }}-deploy
cancel-in-progress: true
steps:
- uses: actions/download-artifact@v3
with:
name: aws-task-definition-artifact
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Update AWS ECS Task Definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: ${{ env.ECS_TASK_CONTAINER_NAME }}
image: ${{ needs.docker-build.outputs.image-tag }}
- name: Deploy AWS ECS Task Definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}