feat(payment-stripe): update currency conversions (#171) #458
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build microservices | |
on: | |
push: | |
branches: [ staging, prod ] | |
jobs: | |
changed-microservices: | |
name: Get changed microservices & set tags | |
runs-on: ubuntu-latest | |
outputs: | |
microservices: ${{ steps.microservices.outputs.list }} | |
microservices-spaced: ${{ steps.microservices.outputs.list-spaced }} | |
branch: ${{ steps.other-params.outputs.branch }} | |
docker-tag: ${{ steps.other-params.outputs.docker-tag }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 30 | |
- run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc | |
- name: Branch name & docker tag & latest release sha | |
id: other-params | |
shell: bash | |
run: | | |
# ignore errors | |
set +e | |
branch=$(echo ${GITHUB_REF#refs/heads/}) | |
git fetch --tags origin $branch | |
tag=$(git describe --tags --abbrev=0 2>/dev/null) | |
sha=$(git --no-pager log -1 --format="%H" "$tag" 2>/dev/null || git rev-list --max-parents=0 HEAD) | |
echo "branch=$branch" >> $GITHUB_OUTPUT | |
echo "sha=$sha" >> $GITHUB_OUTPUT | |
# define docker tag | |
if [ "$branch" == "staging" ]; then | |
echo "docker-tag=-$branch" >> $GITHUB_OUTPUT | |
else | |
echo "docker-tag=" >> $GITHUB_OUTPUT | |
fi | |
echo "tag=$tag && sha=$sha" | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v35 | |
with: | |
json: true | |
dir_names: true | |
dir_names_max_depth: 3 | |
base_sha: ${{ steps.other-params.outputs.sha }} | |
- id: microservices | |
run: npx @lomray/microservices-cli changed-microservices | |
env: | |
FILES: '${{ steps.changed-files.outputs.all_changed_files }}' | |
checks-compile: | |
name: Code checks & compile & npm publish | |
needs: changed-microservices | |
runs-on: ubuntu-latest | |
if: needs.changed-microservices.outputs.microservices-spaced != '' | |
env: | |
ONLY: ${{ needs.changed-microservices.outputs.microservices-spaced }} | |
steps: | |
- uses: actions/checkout@v3 | |
- run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18.13.0' | |
cache: 'npm' | |
- name: Install global dependencies | |
run: npm ci | |
- name: Install microservices dependencies | |
run: npx @lomray/microservices-cli global-install | |
- name: Check microservice eslint | |
run: npx @lomray/microservices-cli lint | |
- name: Check microservice typescript | |
run: npx @lomray/microservices-cli ts-check | |
- name: Run microservices tests with coverage | |
run: npx @lomray/microservices-cli test --coverage | |
- name: Compile microservices | |
run: npx @lomray/microservices-cli build | |
# note: this also update package.json version | |
- name: Publish npm packages / create github release | |
run: npx @lomray/microservices-cli semantic-release | |
env: | |
GIT_BRANCH: ${{ needs.changed-microservices.outputs.branch }} | |
PUBLISH_PACKAGE: ${{ secrets.PUBLISH_PACKAGE }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Archive microservices artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: microservice-artifacts | |
path: | | |
microservices/*/lib/* | |
# keep update version | |
microservices/*/package.json | |
- name: Archive Dockerfile | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dockerfile | |
path: node_modules/@lomray/microservice-config/Dockerfile-nodejs | |
- name: Archive code coverage artifacts | |
uses: actions/upload-artifact@v3 | |
# only for staging | |
if: ${{ needs.changed-microservices.outputs.branch }} == "staging" | |
with: | |
name: coverage-artifacts | |
path: | | |
microservices/*/coverage/* | |
build-docker: | |
name: Build docker images | |
needs: [changed-microservices, checks-compile] | |
runs-on: ubuntu-latest | |
if: needs.changed-microservices.outputs.microservices != '' | |
strategy: | |
matrix: | |
microservice: ${{ fromJson(needs.changed-microservices.outputs.microservices) }} | |
env: | |
MICROSERVICE_NAME: ${{ matrix.microservice }} | |
WORK_DIR: "microservices/${{ matrix.microservice }}" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc | |
- uses: actions/download-artifact@v3 | |
with: | |
name: microservice-artifacts | |
path: microservices | |
- uses: actions/download-artifact@v3 | |
with: | |
name: dockerfile | |
- id: package-version | |
run: npx @lomray/microservices-cli package-version | |
env: | |
WORK_DIR: ${{ env.WORK_DIR }} | |
- name: Detect dockerfile | |
id: docker-file | |
run: npx @lomray/microservices-cli detect-docker-file | |
env: | |
WORK_DIR: '${{ env.WORK_DIR }}' | |
- name: Publish to Registry | |
uses: elgohr/Publish-Docker-Github-Action@v5 | |
env: | |
FROM_TAG: "latest${{ needs.changed-microservices.outputs.docker-tag }}" | |
with: | |
name: "Lomray-Software/microservices/${{ env.MICROSERVICE_NAME }}" | |
tags: "latest${{ needs.changed-microservices.outputs.docker-tag }},${{ steps.package-version.outputs.version}}" | |
dockerfile: ${{ steps.docker-file.outputs.path }} | |
context: ${{ env.WORK_DIR }} | |
buildoptions: "--compress --force-rm --no-cache" | |
buildargs: FROM_TAG | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
registry: ghcr.io | |
sonarcube: | |
name: Sonarcube | |
needs: [changed-microservices, checks-compile] | |
runs-on: ubuntu-latest | |
# only for staging | |
if: ${{ (needs.changed-microservices.outputs.microservices != '') && (needs.changed-microservices.outputs.branch == 'staging') }} | |
strategy: | |
matrix: | |
microservice: ${{ fromJson(needs.changed-microservices.outputs.microservices) }} | |
env: | |
MICROSERVICE_NAME: ${{ matrix.microservice }} | |
WORK_DIR: "microservices/${{ matrix.microservice }}" | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: coverage-artifacts | |
path: microservices | |
- id: package-version | |
run: npx @lomray/microservices-cli package-version | |
env: | |
WORK_DIR: ${{ env.WORK_DIR }} | |
- uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_CLOUD_TOKEN }} | |
with: | |
projectBaseDir: ${{ env.WORK_DIR }} | |
args: > | |
-Dsonar.projectVersion=${{ steps.package-version.outputs.version }} |