Skip to content

Commit 16a3f21

Browse files
add: uptime-kuma and workflow files (#1)
* add: uptime-kuma and workflow files * imp: use latest uptime kuma for better DB management * ref(deploy): allow an external `mariadb` database * fix(db): patch `knex_init_db.js` file * fix(runtime): avoid spawning zombie processes * chore: do not commit `trunk` linting confs * fix(actions): permissions * imp(deploy): use secrets from GCP secret manager
1 parent 7dac323 commit 16a3f21

15 files changed

+1291
-0
lines changed

.github/dependabot.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: docker
4+
directory: /
5+
schedule:
6+
interval: monthly
7+
commit-message:
8+
prefix: "deps(docker) "
9+
10+
- package-ecosystem: github-actions
11+
directory: /
12+
schedule:
13+
interval: monthly
14+
commit-message:
15+
prefix: "deps(actions) "
16+
groups:
17+
devops:
18+
patterns:
19+
- "*"
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Deploy to dev
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, labeled]
6+
paths:
7+
- '**/Dockerfile'
8+
- 'scripts/**'
9+
- 'etc/litestream.yml'
10+
- .github/workflows/cd-deploy-to-dev.yml
11+
- .github/workflows/sub-cloudrun-deploy.yml
12+
13+
concurrency:
14+
# Ensures that only one workflow task will run at a time. Previous builds, if
15+
# already in process, will get cancelled. Only the latest commit will be allowed
16+
# to run, cancelling any workflows in between
17+
group: ${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.run_id }}
18+
cancel-in-progress: true
19+
20+
permissions:
21+
actions: read
22+
attestations: read
23+
checks: read
24+
contents: read
25+
deployments: read
26+
id-token: write
27+
issues: read
28+
discussions: read
29+
packages: read
30+
pages: read
31+
pull-requests: read
32+
repository-projects: read
33+
security-events: read
34+
statuses: read
35+
36+
jobs:
37+
build:
38+
uses: ./.github/workflows/sub-build-docker-image.yml
39+
with:
40+
environment: dev
41+
dockerfile_path: ./docker/Dockerfile
42+
dockerfile_target: runner
43+
app_name: ${{ vars.APP_NAME }}
44+
registry: ${{ vars.GAR_BASE }}
45+
secrets: inherit
46+
47+
deploy:
48+
needs: [build]
49+
uses: ./.github/workflows/sub-cloudrun-deploy.yml
50+
with:
51+
environment: dev
52+
project_id: ${{ vars.GCP_PROJECT }}
53+
region: ${{ vars.GCP_REGION }}
54+
app_name: ${{ vars.APP_NAME }}
55+
registry: ${{ vars.GAR_BASE }}
56+
image_digest: ${{ needs.build.outputs.image_digest }}
57+
min_instances: '0'
58+
max_instances: '30'
59+
cpu: '1'
60+
memory: 1Gi
61+
secrets: inherit
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Deploy to prod
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
concurrency:
9+
# Ensures that only one workflow task will run at a time. Previous builds, if
10+
# already in process, will get cancelled. Only the latest commit will be allowed
11+
# to run, cancelling any workflows in between
12+
group: ${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
permissions:
16+
actions: read
17+
attestations: read
18+
checks: read
19+
contents: read
20+
deployments: read
21+
id-token: write
22+
issues: read
23+
discussions: read
24+
packages: read
25+
pages: read
26+
pull-requests: read
27+
repository-projects: read
28+
security-events: read
29+
statuses: read
30+
31+
jobs:
32+
build:
33+
# needs: [test]
34+
uses: ./.github/workflows/sub-build-docker-image.yml
35+
with:
36+
environment: prod
37+
dockerfile_path: ./docker/Dockerfile
38+
dockerfile_target: runner
39+
app_name: ${{ vars.APP_NAME }}
40+
registry: ${{ vars.GAR_BASE }}
41+
secrets: inherit
42+
43+
deploy:
44+
needs: [build]
45+
uses: ./.github/workflows/sub-cloudrun-deploy.yml
46+
with:
47+
environment: prod
48+
project_id: ${{ vars.GCP_PROJECT }}
49+
region: ${{ vars.GCP_REGION }}
50+
app_name: ${{ vars.APP_NAME }}
51+
registry: ${{ vars.GAR_BASE }}
52+
image_digest: ${{ needs.build.outputs.image_digest }}
53+
min_instances: '1'
54+
max_instances: '10'
55+
cpu: '1'
56+
memory: 1Gi
57+
secrets: inherit
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Deploy to test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- '**/Dockerfile'
9+
- 'scripts/**'
10+
- 'etc/litestream.yml'
11+
- .github/workflows/cd-deploy-to-test.yml
12+
- .github/workflows/sub-cloudrun-deploy.yml
13+
14+
concurrency:
15+
# Ensures that only one workflow task will run at a time. Previous builds, if
16+
# already in process, will get cancelled. Only the latest commit will be allowed
17+
# to run, cancelling any workflows in between
18+
group: ${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.run_id }}
19+
cancel-in-progress: true
20+
21+
permissions:
22+
actions: read
23+
attestations: read
24+
checks: read
25+
contents: read
26+
deployments: read
27+
id-token: write
28+
issues: read
29+
discussions: read
30+
packages: read
31+
pages: read
32+
pull-requests: read
33+
repository-projects: read
34+
security-events: read
35+
statuses: read
36+
37+
jobs:
38+
build:
39+
uses: ./.github/workflows/sub-build-docker-image.yml
40+
with:
41+
environment: test
42+
dockerfile_path: ./docker/Dockerfile
43+
dockerfile_target: runner
44+
app_name: ${{ vars.APP_NAME }}
45+
registry: ${{ vars.GAR_BASE }}
46+
secrets: inherit
47+
48+
deploy:
49+
needs: [build]
50+
uses: ./.github/workflows/sub-cloudrun-deploy.yml
51+
with:
52+
environment: test
53+
project_id: ${{ vars.GCP_PROJECT }}
54+
region: ${{ vars.GCP_REGION }}
55+
app_name: ${{ vars.APP_NAME }}
56+
registry: ${{ vars.GAR_BASE }}
57+
image_digest: ${{ needs.build.outputs.image_digest }}
58+
min_instances: '0'
59+
max_instances: '30'
60+
cpu: '1'
61+
memory: 1Gi
62+
secrets: inherit

.github/workflows/chore-clean-dev.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Clean dev instances
2+
3+
on:
4+
delete:
5+
pull_request:
6+
branches:
7+
- main
8+
types:
9+
- closed
10+
11+
permissions: read-all
12+
13+
jobs:
14+
delete:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: 'read'
18+
id-token: 'write'
19+
steps:
20+
- name: Inject slug/short variables
21+
uses: rlespinasse/[email protected]
22+
23+
- name: Authenticate to Google Cloud
24+
id: auth
25+
uses: google-github-actions/[email protected]
26+
with:
27+
workload_identity_provider: '${{ vars.GCP_WIF }}'
28+
project_id: '${{ vars.GCP_PROJECT }}'
29+
30+
- name: Set up Cloud SDK
31+
uses: google-github-actions/[email protected]
32+
33+
- name: Removing CR service
34+
run: |
35+
gcloud run services delete ${{ vars.APP_NAME }}-${{ env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }} --region=${{ vars.GOOGLE_CLOUD_REGION }} --quiet
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Lint Code Base
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
paths-ignore:
7+
- '**/Dockerfile'
8+
- 'scripts/**'
9+
- 'etc/litestream.yml'
10+
- .github/workflows/ci-lint-codebase.yml
11+
12+
permissions: read-all
13+
14+
jobs:
15+
linter:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- run: echo "Job not required"
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Lint Code Base
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
paths:
7+
- '**/Dockerfile'
8+
- 'scripts/**'
9+
- 'etc/litestream.yml'
10+
- .github/workflows/ci-lint-codebase.yml
11+
12+
push:
13+
branches: [main]
14+
paths:
15+
- '**.sh*'
16+
- '**.ts*'
17+
- Dockerfile
18+
- package.json
19+
- pnpm-lock.yaml
20+
- .github/workflows/ci-lint-codebase.yml
21+
22+
concurrency:
23+
# Ensures that only one workflow task will run at a time. Previous builds, if
24+
# already in process, will get cancelled. Only the latest commit will be allowed
25+
# to run, cancelling any workflows in between
26+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
27+
cancel-in-progress: true
28+
29+
permissions: read-all
30+
31+
jobs:
32+
linter:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout Code Repository
36+
uses: actions/[email protected]
37+
with:
38+
# Full git history is needed to get a proper
39+
# list of changed files within `super-linter`
40+
fetch-depth: 0
41+
42+
- name: Lint Code Base
43+
uses: super-linter/super-linter/[email protected]
44+
env:
45+
LOG_LEVEL: ERROR
46+
VALIDATE_ALL_CODEBASE: false
47+
VALIDATE_SHELL_SHFMT: false
48+
VALIDATE_JSCPD: false
49+
VALIDATE_CSS: false
50+
VALIDATE_EDITORCONFIG: false
51+
VALIDATE_MARKDOWN: false
52+
VALIDATE_JAVASCRIPT_ES: false
53+
VALIDATE_JAVASCRIPT_STANDARD: false
54+
VALIDATE_DOCKERFILE_HADOLINT: false
55+
LINTER_RULES_PATH: /
56+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)