Skip to content

Commit 8f2feef

Browse files
committed
ci: update build workflow to deploy to dev
1 parent 4961f37 commit 8f2feef

8 files changed

Lines changed: 396 additions & 35 deletions

File tree

.github/workflows/build.yml

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ on:
1616
- Skip
1717
- Staging Only
1818
- Staging + Prod
19-
sandbox:
20-
description: 'Deploy to Sandbox'
19+
dev:
20+
description: 'Deploy to Dev'
2121
default: true
2222
required: true
2323
type: boolean
24-
sandboxNoDbRefresh:
25-
description: 'Sandbox Disable Daily DB Refresh'
24+
devNoDbRefresh:
25+
description: 'Dev Disable Daily DB Refresh'
2626
default: false
2727
required: true
2828
type: boolean
@@ -392,44 +392,45 @@ jobs:
392392
value: "Failed"
393393
394394
# -----------------------------------------------------------------
395-
# SANDBOX
395+
# DEV
396396
# -----------------------------------------------------------------
397-
sandbox:
398-
name: Deploy to Sandbox
399-
if: ${{ !failure() && !cancelled() && github.event.inputs.sandbox == 'true' }}
397+
dev:
398+
name: Deploy to Dev
399+
if: ${{ !failure() && !cancelled() && github.event.inputs.dev == 'true' }}
400400
needs: [prepare, release]
401-
runs-on: [self-hosted, dev-server]
401+
runs-on: ubuntu-latest
402402
environment:
403-
name: sandbox
403+
name: dev
404404
env:
405405
PKG_VERSION: ${{needs.prepare.outputs.pkg_version}}
406406

407407
steps:
408-
- uses: actions/checkout@v4
409-
410-
- name: Download a Release Artifact
411-
uses: actions/download-artifact@v4.3.0
412-
with:
413-
name: release-${{ env.PKG_VERSION }}
414-
415-
- name: Deploy to containers
416-
env:
417-
DEBIAN_FRONTEND: noninteractive
418-
run: |
419-
echo "Reset production flags in settings.py..."
420-
sed -i -r -e 's/^DEBUG *= *.*$/DEBUG = True/' -e "s/^SERVER_MODE *= *.*\$/SERVER_MODE = 'development'/" ietf/settings.py
421-
echo "Install Deploy to Container CLI dependencies..."
422-
cd dev/deploy-to-container
423-
npm ci
424-
cd ../..
425-
echo "Start Deploy..."
426-
node ./dev/deploy-to-container/cli.js --branch ${{ github.ref_name }} --domain dev.ietf.org --appversion ${{ env.PKG_VERSION }} --commit ${{ github.sha }} --ghrunid ${{ github.run_id }} --nodbrefresh ${{ github.event.inputs.sandboxNoDbRefresh }}
427-
428-
- name: Cleanup old docker resources
429-
env:
430-
DEBIAN_FRONTEND: noninteractive
431-
run: |
432-
docker image prune -a -f
408+
- uses: actions/checkout@v4
409+
with:
410+
ref: main
411+
412+
- name: Get Deploy Name
413+
env:
414+
DEBIAN_FRONTEND: noninteractive
415+
run: |
416+
echo "Install Get Deploy Name CLI dependencies..."
417+
cd dev/k8s-get-deploy-name
418+
npm ci
419+
echo "Get Deploy Name..."
420+
echo "DEPLOY_NAMESPACE=$(node cli.js --branch ${{ github.ref_name }})" >> "$GITHUB_ENV"
421+
422+
- name: Deploy to dev
423+
uses: the-actions-org/workflow-dispatch@v4
424+
with:
425+
workflow: deploy-dev.yml
426+
repo: ietf-tools/infra-k8s
427+
ref: main
428+
token: ${{ secrets.GH_INFRA_K8S_TOKEN }}
429+
inputs: '{ "app":"datatracker", "appVersion":"${{ env.PKG_VERSION }}", "remoteRef":"${{ github.sha }}", "namespace":"${{ env.DEPLOY_NAMESPACE }}" }'
430+
wait-for-completion: true
431+
wait-for-completion-timeout: 30m
432+
wait-for-completion-interval: 30s
433+
display-workflow-run-url: false
433434

434435
# -----------------------------------------------------------------
435436
# STAGING
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[*]
2+
indent_size = 2
3+
indent_style = space
4+
charset = utf-8
5+
trim_trailing_whitespace = false
6+
end_of_line = lf
7+
insert_final_newline = true

dev/k8s-get-deploy-name/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules

dev/k8s-get-deploy-name/.npmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
audit = false
2+
fund = false
3+
save-exact = true

dev/k8s-get-deploy-name/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Datatracker Get Deploy Name
2+
3+
This tool process and slugify a git branch into an appropriate subdomain name.
4+
5+
## Usage
6+
7+
1. From the `dev/k8s-get-deploy-name` directory, install the dependencies:
8+
```sh
9+
npm install
10+
```
11+
2. Run the command: (replacing the `branch` argument)
12+
```sh
13+
node /cli.js --branch feat/fooBar-123
14+
```
15+
16+
The subdomain name will be output. It can then be used in a workflow as a namespace name and subdomain value.

dev/k8s-get-deploy-name/cli.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env node
2+
3+
import yargs from 'yargs/yargs'
4+
import { hideBin } from 'yargs/helpers'
5+
import slugify from 'slugify'
6+
7+
const argv = yargs(hideBin(process.argv)).argv
8+
9+
let branch = argv.branch
10+
if (!branch) {
11+
throw new Error('Missing --branch argument!')
12+
}
13+
if (branch.indexOf('/') >= 0) {
14+
branch = branch.split('/').slice(1).join('-')
15+
}
16+
branch = slugify(branch, { lower: true, strict: true })
17+
if (branch.length < 1) {
18+
throw new Error('Branch name is empty!')
19+
}
20+
process.stdout.write(`dt-${branch}`)
21+
22+
process.exit(0)

0 commit comments

Comments
 (0)