diff --git a/.github/workflows/analytics.yml b/.github/workflows/analytics.yml index 96ce9f40f..2217ebdbe 100644 --- a/.github/workflows/analytics.yml +++ b/.github/workflows/analytics.yml @@ -11,19 +11,18 @@ on: workflow_dispatch: jobs: - call_server_application_workflow: - name: Server Application - uses: standardnotes/server/.github/workflows/common-server-application.yml@main + call_server_utility_workflow: + name: Server Utility + uses: standardnotes/server/.github/workflows/common-server-utility.yml@main with: service_name: analytics workspace_name: "@standardnotes/analytics" - e2e_tag_parameter_name: analytics_image_tag deploy_web: false package_path: packages/analytics secrets: inherit newrelic: - needs: call_server_application_workflow + needs: call_server_utility_workflow runs-on: ubuntu-latest diff --git a/.github/workflows/common-server-utility.yml b/.github/workflows/common-server-utility.yml new file mode 100644 index 000000000..c9209a85b --- /dev/null +++ b/.github/workflows/common-server-utility.yml @@ -0,0 +1,164 @@ +name: Reusable Server Utility Workflow + +on: + workflow_call: + inputs: + service_name: + required: true + type: string + workspace_name: + required: true + type: string + deploy_web: + required: false + default: true + type: boolean + deploy_worker: + required: false + default: true + type: boolean + package_path: + required: true + type: string + secrets: + DOCKER_USERNAME: + required: true + DOCKER_PASSWORD: + required: true + CI_PAT_TOKEN: + required: true + AWS_ACCESS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + +jobs: + build: + runs-on: ubuntu-latest + + outputs: + temp_dir: ${{ steps.bundle-dir.outputs.temp_dir }} + + steps: + - uses: actions/checkout@v3 + + - name: Create Bundle Dir + id: bundle-dir + run: echo "temp_dir=$(mktemp -d -t ${{ inputs.service_name }}-${{ github.sha }}-XXXXXXX)" >> $GITHUB_OUTPUT + + - name: Cache build + id: cache-build + uses: actions/cache@v3 + with: + path: | + packages/**/dist + ${{ steps.bundle-dir.outputs.temp_dir }} + key: ${{ runner.os }}-${{ inputs.service_name }}-build-${{ github.sha }} + + - name: Set up Node + uses: actions/setup-node@v3 + with: + registry-url: 'https://registry.npmjs.org' + node-version-file: '.nvmrc' + + - name: Build + run: yarn build ${{ inputs.package_path }} + + - name: Bundle + run: yarn workspace ${{ inputs.workspace_name }} bundle --no-compress --output-directory ${{ steps.bundle-dir.outputs.temp_dir }} + + lint: + runs-on: ubuntu-latest + + needs: build + + steps: + - uses: actions/checkout@v3 + + - name: Cache build + id: cache-build + uses: actions/cache@v3 + with: + path: | + packages/**/dist + ${{ needs.build.outputs.temp_dir }} + key: ${{ runner.os }}-${{ inputs.service_name }}-build-${{ github.sha }} + + - name: Set up Node + uses: actions/setup-node@v3 + with: + registry-url: 'https://registry.npmjs.org' + node-version-file: '.nvmrc' + + - name: Build + if: steps.cache-build.outputs.cache-hit != 'true' + run: yarn build ${{ inputs.package_path }} + + - name: Lint + run: yarn lint:${{ inputs.service_name }} + + test: + runs-on: ubuntu-latest + + needs: build + + steps: + - uses: actions/checkout@v3 + + - name: Cache build + id: cache-build + uses: actions/cache@v3 + with: + path: | + packages/**/dist + ${{ needs.build.outputs.temp_dir }} + key: ${{ runner.os }}-${{ inputs.service_name }}-build-${{ github.sha }} + + - name: Set up Node + uses: actions/setup-node@v3 + with: + registry-url: 'https://registry.npmjs.org' + node-version-file: '.nvmrc' + + - name: Build + if: steps.cache-build.outputs.cache-hit != 'true' + run: yarn build ${{ inputs.package_path }} + + - name: Test + run: yarn test ${{ inputs.package_path }} + + publish: + needs: [ build, test, lint ] + + name: Publish Docker Image + uses: standardnotes/server/.github/workflows/common-docker-image.yml@main + with: + service_name: ${{ inputs.service_name }} + bundle_dir: ${{ needs.build.outputs.temp_dir }} + package_path: ${{ inputs.package_path }} + workspace_name: ${{ inputs.workspace_name }} + secrets: inherit + + deploy-web: + if: ${{ inputs.deploy_web }} + + needs: publish + + name: Deploy Web + uses: standardnotes/server/.github/workflows/common-deploy.yml@main + with: + service_name: ${{ inputs.service_name }} + docker_image: ${{ inputs.service_name }}:${{ github.sha }} + secrets: inherit + + deploy-worker: + if: ${{ inputs.deploy_worker }} + + needs: publish + + name: Deploy Worker + uses: standardnotes/server/.github/workflows/common-deploy.yml@main + with: + service_name: ${{ inputs.service_name }}-worker + docker_image: ${{ inputs.service_name }}:${{ github.sha }} + secrets: inherit diff --git a/.github/workflows/event-store.yml b/.github/workflows/event-store.yml index ec6d5eae4..b3b77c72c 100644 --- a/.github/workflows/event-store.yml +++ b/.github/workflows/event-store.yml @@ -11,19 +11,18 @@ on: workflow_dispatch: jobs: - call_server_application_workflow: - name: Server Application - uses: standardnotes/server/.github/workflows/common-server-application.yml@main + call_server_utility_workflow: + name: Server Utility + uses: standardnotes/server/.github/workflows/common-server-utility.yml@main with: service_name: event-store workspace_name: "@standardnotes/event-store" - e2e_tag_parameter_name: event_store_image_tag deploy_web: false package_path: packages/event-store secrets: inherit newrelic: - needs: call_server_application_workflow + needs: call_server_utility_workflow runs-on: ubuntu-latest diff --git a/.github/workflows/scheduler.yml b/.github/workflows/scheduler.yml index f03d6e632..f9f84a131 100644 --- a/.github/workflows/scheduler.yml +++ b/.github/workflows/scheduler.yml @@ -11,19 +11,18 @@ on: workflow_dispatch: jobs: - call_server_application_workflow: - name: Server Application - uses: standardnotes/server/.github/workflows/common-server-application.yml@main + call_server_utility_workflow: + name: Server Utility + uses: standardnotes/server/.github/workflows/common-server-utility.yml@main with: service_name: scheduler workspace_name: "@standardnotes/scheduler-server" - e2e_tag_parameter_name: scheduler_image_tag deploy_web: false package_path: packages/scheduler secrets: inherit newrelic: - needs: call_server_application_workflow + needs: call_server_utility_workflow runs-on: ubuntu-latest diff --git a/.github/workflows/websockets.yml b/.github/workflows/websockets.yml index fb00dfab5..4dd55296f 100644 --- a/.github/workflows/websockets.yml +++ b/.github/workflows/websockets.yml @@ -11,18 +11,17 @@ on: workflow_dispatch: jobs: - call_server_application_workflow: - name: Server Application - uses: standardnotes/server/.github/workflows/common-server-application.yml@main + call_server_utility_workflow: + name: Server Utility + uses: standardnotes/server/.github/workflows/common-server-utility.yml@main with: service_name: websockets workspace_name: "@standardnotes/websockets-server" - e2e_tag_parameter_name: websockets_image_tag package_path: packages/websockets secrets: inherit newrelic: - needs: call_server_application_workflow + needs: call_server_utility_workflow runs-on: ubuntu-latest steps: diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index a141c529f..deadc10dd 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -11,18 +11,17 @@ on: workflow_dispatch: jobs: - call_server_application_workflow: - name: Server Application - uses: standardnotes/server/.github/workflows/common-server-application.yml@main + call_server_utility_workflow: + name: Server Utility + uses: standardnotes/server/.github/workflows/common-server-utility.yml@main with: service_name: workspace workspace_name: "@standardnotes/workspace-server" - e2e_tag_parameter_name: workspace_image_tag package_path: packages/workspace secrets: inherit newrelic: - needs: call_server_application_workflow + needs: call_server_utility_workflow runs-on: ubuntu-latest steps: