Skip to content

build test

build test #245

Workflow file for this run

name: push-services
on:
push:
branches:
- main
paths:
- "services/**"
env:
SERVICE_TYPE: fe
jobs:
get-versioning:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
outputs:
type: ${{ steps.versioning.outputs.type }}
steps:
- name: Check Out The Repository
uses: actions/checkout@v3
with:
token: ${{ secrets.GHP_TOKEN }}
- name: Get Prefix By Commit
id: get_commit_prefix
run: echo $(echo "${{ github.event.head_commit.message }}" | cut -d ":" -f 1 | cut -d "(" -f 1 | cut -d " " -f 1)
- name: Parse xquare-versioning.json
id: parse_xquare_versioning
run: |
content=`cat ./xquare-versioning.json`
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
echo "::set-output name=xquareVersioning::$content"
- name: Get Do Versioning
id: versioning
run: |
echo "::set-output name=type::${{ fromJson(steps.parse_xquare_versioning.outputs.xquareVersioning).commit.fix }}"
get-diff-workspace:
needs: get-versioning
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check Out The Repository
uses: actions/checkout@v3
with:
fetch-depth: '2'
token: ${{ secrets.GHP_TOKEN }}
- name: diff-workspace
id: set-matrix
run: echo "::set-output name=matrix::{\"workspaces\":[$(yarn changed list --git-range $(git rev-parse HEAD^) --json --exclude xquare-frontend --exclude @shared/xbridge | tr "\n" ",")]}"
build:
name: Build
needs: [get-diff-workspace, get-versioning]
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.get-diff-workspace.outputs.matrix) }}
steps:
- name: Login to ECR
id: ecr
uses: elgohr/ecr-login-action@master
with:
access_key: ${{ secrets.AWS_ACCESS_KEY }}
secret_access_key: ${{ secrets.AWS_SECRET_KEY }}
region: ${{ secrets.AWS_REGION }}
- name: Login to Docker
run: docker login -u ${{ steps.ecr.outputs.username }} -p ${{ steps.ecr.outputs.password }} https://${{ secrets.AWS_SPECIFIC_URI }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
- name: Check Out The Repository
uses: actions/checkout@v3
with:
token: ${{ secrets.GHP_TOKEN }}
- name: Get Service
id: get_service
run: echo ::set-output name=SERVICE::$(echo ${{ matrix.workspaces.name }} | cut -d / -f 2)
- name: Sync Package Version
run: yarn workspace @service/${{ steps.get_service.outputs.SERVICE }} version ${{ needs.get-versioning.outputs.type }}
- name: Get Package Version
id: package-version
uses: martinbeentjes/npm-get-version-action@main
with:
path: ${{ matrix.workspaces.location }}
- name: Docker Build
run: yarn docker build @service/${{steps.get_service.outputs.SERVICE}} -t ${{ secrets.AWS_SPECIFIC_URI }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{steps.get_service.outputs.SERVICE}}-${{env.SERVICE_TYPE}}:${{ steps.package-version.outputs.current-version}}
- name: Docker Push
run: docker push ${{ secrets.AWS_SPECIFIC_URI }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{steps.get_service.outputs.SERVICE}}-${{env.SERVICE_TYPE}}:${{ steps.package-version.outputs.current-version}}
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.GITOPS_DEPLOY_STAGE_TOKEN }}
repository: team-xquare/xquare-gitops-repo-production
event-type: update_image
client-payload: '{
"ref": "${{ github.ref }}",
"version": "${{ steps.package-version.outputs.current-version}}",
"service_name": "${{steps.get_service.outputs.SERVICE}}",
"service_type": "${{ env.SERVICE_TYPE }}"
}'
- name: Pull Commit
run: git pull
- name: Commit With Versioning
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "release(${{steps.get_service.outputs.SERVICE}}): ${{ steps.package-version.outputs.current-version }} [skip ci]"
branch: main
commit_options: '--no-verify --signoff'
repository: .
commit_user_name: XQUARE Frontend Bot
commit_user_email: [email protected]
commit_author: XQUARE Frontend Bot <[email protected]>