-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modularize Github Action usage with shared workflows (#200)
* Modularize Github Action usage with shared workflows. * Prefix shared workflows with "_", since we can't have subdirectories in .github/workflows * Remove shared _setup.yml workflow and duplicate its steps in the terraform and validate workflows (we can't reused the outputs across jobs)
- Loading branch information
1 parent
a5c02fd
commit fd6941b
Showing
5 changed files
with
193 additions
and
152 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Apply Terraform CDK configuration | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
apply-terraform: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Read node version from `.nvmrc` file | ||
id: nvmrc | ||
shell: bash | ||
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc) | ||
|
||
- name: Install required node.js version | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }} | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
id: pnpm-install | ||
with: | ||
version: 8 | ||
run_install: false | ||
|
||
- name: Get pnpm store directory | ||
id: pnpm-cache | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | ||
- uses: actions/cache@v3 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Initialize Terraform CDK configuration | ||
shell: bash | ||
run: | | ||
cd infra | ||
pnpm cdktf get | ||
pnpm build:tsc | ||
- name: Install CloudFoundry CLI | ||
run: | | ||
curl -L "https://packages.cloudfoundry.org/stable?release=linux64-binary&version=v8&source=github" | sudo tar -zx --directory=/usr/local/bin | ||
cf --version | ||
- name: Apply Terraform CDK configuration | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
shell: bash | ||
run: | | ||
cd infra | ||
cf api https://api.fr.cloud.gov | ||
DEPLOY_ENV=${TAG_NAME} pnpm cdktf deploy --auto-approve |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Build Docker image | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
app-name: | ||
required: true | ||
type: string | ||
repo-name: | ||
type: string | ||
default: ${{ github.repository }} | ||
|
||
env: | ||
TAG_NAME: ${{ github.ref_name }} | ||
APP_DIR: ${{ inputs.app-name }} | ||
REGISTRY_PATH: ghcr.io/${{ inputs.repo-name }}/${{ inputs.app-name }} | ||
|
||
jobs: | ||
setup: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build Docker image | ||
run: | | ||
docker build . --platform linux/amd64 --target app --build-arg APP_DIR=${APP_DIR} --tag ${REGISTRY_PATH}:${github.sha} | ||
- name: Tag Docker image | ||
run: | | ||
docker tag ${REGISTRY_PATH}:${github.sha} ${REGISTRY_PATH}:${TAG_NAME} | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Publish to container registry | ||
run: | | ||
docker push --all-tags ${REGISTRY_PATH} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Validate | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
run-tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Read node version from `.nvmrc` file | ||
id: nvmrc | ||
shell: bash | ||
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc) | ||
|
||
- name: Install required node.js version | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }} | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
id: pnpm-install | ||
with: | ||
version: 8 | ||
run_install: false | ||
|
||
- name: Get pnpm store directory | ||
id: pnpm-cache | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | ||
- uses: actions/cache@v3 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Lint source code | ||
shell: bash | ||
run: pnpm lint | ||
|
||
- name: Run test suite | ||
shell: bash | ||
run: pnpm test | ||
|
||
- name: Initialize Terraform CDK configuration | ||
shell: bash | ||
run: | | ||
cd infra | ||
pnpm cdktf get | ||
pnpm build:tsc | ||
- name: Typecheck source code | ||
shell: bash | ||
run: pnpm typecheck | ||
|
||
#- name: Vitest Coverage Report | ||
# if: always() | ||
# uses: davelosert/[email protected] |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,70 +8,4 @@ on: | |
|
||
jobs: | ||
run-tests: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest] | ||
arch: [x86_64] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Read node version from `.nvmrc` file | ||
id: nvmrc | ||
shell: bash | ||
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc) | ||
|
||
- name: Install required node.js version | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }} | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
id: pnpm-install | ||
with: | ||
version: 8 | ||
run_install: false | ||
|
||
- name: Get pnpm store directory | ||
id: pnpm-cache | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | ||
- uses: actions/cache@v3 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Lint source code | ||
shell: bash | ||
run: pnpm lint | ||
|
||
- name: Run test suite | ||
shell: bash | ||
run: pnpm test | ||
|
||
- name: Initialize Terraform CDK configuration | ||
shell: bash | ||
run: | | ||
cd infra | ||
pnpm cdktf get | ||
pnpm build:tsc | ||
- name: Typecheck source code | ||
shell: bash | ||
run: pnpm typecheck | ||
|
||
#- name: Vitest Coverage Report | ||
# if: always() | ||
# uses: davelosert/[email protected] | ||
uses: ./.github/workflows/_validate.yml |