Skip to content

Commit

Permalink
Merge branch 'main' into feat/local-storage
Browse files Browse the repository at this point in the history
  • Loading branch information
kasugamirai authored Sep 17, 2024
2 parents 9c78d81 + 223bb57 commit 409536a
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 112 deletions.
65 changes: 31 additions & 34 deletions .github/actions/build_deploy_api/action.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
name: build-deploy-api
on:
workflow_call:
inputs:
sha_short:
required: true
type: string
new_tag:
required: true
type: string
new_tag_short:
required: true
type: string
name:
required: true
type: string
sha:
required: true
type: string
description: Build and deploy the API
inputs:
sha_short:
required: true
type: string
new_tag:
required: true
type: string
new_tag_short:
required: true
type: string
name:
required: true
type: string
sha:
required: true
type: string

jobs:
build-api:
name: Build and release api
runs-on: ubuntu-latest
if: inputs.name != 'blank' || inputs.new_tag != 'blank'
env:
ARTIFACTS: api/dist/reearth_*.*
steps:
runs:
using: composite
steps:
- name: Checkout
uses: actions/checkout@v3
with:
Expand All @@ -35,14 +29,17 @@ jobs:
with:
go-version: '1.21'
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --rm-dist ${{ inputs.new_tag == 'blank' && '--snapshot' || '' }}
workdir: api
env:
GORELEASER_CURRENT_TAG: ${{ inputs.new_tag == 'blank' && '0.0.0' || inputs.new_tag }}
shell: bash
run: |
if [[ "${{ inputs.name }}" != "blank" || "${{ inputs.new_tag }}" != "blank" ]]; then
args="release --rm-dist"
if [[ "${{ inputs.new_tag }}" == "blank" ]]; then
args="$args --snapshot"
fi
GORELEASER_CURRENT_TAG="${{ inputs.new_tag == 'blank' && '0.0.0' || inputs.new_tag }}"
cd api
goreleaser $args
fi
- name: Rename artifacts
if: ${{ inputs.name != 'blank' }}
run: for f in $ARTIFACTS; do mv $f $(echo $f | sed -E 's/_0\.0\.0-SNAPSHOT-[^_]*/_${{ inputs.name }}/'); done
Expand Down
93 changes: 38 additions & 55 deletions .github/actions/build_deploy_ui/action.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,43 @@
name: build-deploy-ui
on:
workflow_call:
inputs:
sha_short:
required: true
type: string
new_tag:
required: true
type: string
new_tag_short:
required: true
type: string
name:
required: true
type: string
sha:
required: true
type: string
description: Build and deploy the UI
inputs:
sha_short:
required: true
type: string
new_tag:
required: true
type: string
new_tag_short:
required: true
type: string
name:
required: true
type: string
sha:
required: true
type: string

jobs:
build-ui:
name: Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: ui
if: inputs.name != 'blank'
env:
NODE_OPTIONS: "--max-old-space-size=8192"
steps:
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: actions/checkout@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: |
CACHE_DIR=$(yarn cache dir)
echo "dir=$CACHE_DIR" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install
run: yarn install
- name: Build
run: yarn build
- name: Pack
run: mv dist flow-ui && tar -zcvf flow-ui.tar.gz flow-ui
- uses: actions/upload-artifact@v2
with:
name: flow-ui
path: ui/flow-ui.tar.gz
runs:
using: composite
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Build UI
shell: bash
env:
NODE_OPTIONS: "--max-old-space-size=8192"
run: |
if [[ "${{ inputs.name }}" != "blank" ]]; then
cd ui
yarn install
yarn build
tar -zcvf flow-ui.tar.gz dist
mv flow-ui.tar.gz flow-ui_${{ inputs.name }}.tar.gz
fi
release:
name: Release
Expand Down
41 changes: 18 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,36 +128,31 @@ jobs:
NEW_TAG_SHORT: ${{ steps.info.outputs.new_tag_short }}
NAME: ${{ steps.info.outputs.name }}
run: echo "sha_short=$SHA_SHORT, new_tag=$NEW_TAG, new_tag_short=$NEW_TAG_SHORT, name=$NAME"
build-api:
needs:
- ci
- ci-api
- ci-collect-info
runs-on: ubuntu-latest
if: ${{ !failure() && needs.ci-api.result == 'success' && github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'release' || startsWith(github.ref_name, 'release/')) }}
steps:
- uses: ./.github/actions/build_deploy_api
with:
sha_short: ${{ needs.ci-collect-info.outputs.sha_short }}
new_tag: ${{ needs.ci-collect-info.outputs.new_tag }}
new_tag_short: ${{ needs.ci-collect-info.outputs.new_tag_short }}
name: ${{ needs.ci-collect-info.outputs.name }}
sha: ${{ github.sha }}

build-ui:
needs:
- ci
- ci-ui
- ci-collect-info
runs-on: ubuntu-latest
if: ${{!failure() && needs.ci-ui.result == 'success' && github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'release' || startsWith(github.ref_name, 'release/'))}}
steps:
- uses: actions/checkout@v4

- name: Build UI
uses: ./.github/actions/build_deploy_ui
with:
sha_short: ${{ needs.ci-collect-info.outputs.sha_short }}
new_tag: ${{ needs.ci-collect-info.outputs.new_tag }}
new_tag_short: ${{ needs.ci-collect-info.outputs.new_tag_short }}
name: ${{ needs.ci-collect-info.outputs.name }}
sha: ${{ github.sha }}
build-api:
needs:
- ci
- ci-api
- ci-collect-info
runs-on: ubuntu-latest
if: ${{!failure() && needs.ci-api.result == 'success' && github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'release' || startsWith(github.ref_name, 'release/'))}}
if: ${{ !failure() && needs.ci-ui.result == 'success' && github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'release' || startsWith(github.ref_name, 'release/')) }}
steps:
- uses: actions/checkout@v4

- name: Build API
uses: ./.github/actions/build_deploy_api
- uses: ./.github/actions/build_deploy_ui
with:
sha_short: ${{ needs.ci-collect-info.outputs.sha_short }}
new_tag: ${{ needs.ci-collect-info.outputs.new_tag }}
Expand Down

0 comments on commit 409536a

Please sign in to comment.