Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 36 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ on:
- Skip
- Staging Only
- Staging + Prod
sandbox:
description: 'Deploy to Sandbox'
dev:
description: 'Deploy to Dev'
default: true
required: true
type: boolean
sandboxNoDbRefresh:
description: 'Sandbox Disable Daily DB Refresh'
devNoDbRefresh:
description: 'Dev Disable Daily DB Refresh'
default: false
required: true
type: boolean
Expand Down Expand Up @@ -392,44 +392,45 @@ jobs:
value: "Failed"

# -----------------------------------------------------------------
# SANDBOX
# DEV
# -----------------------------------------------------------------
sandbox:
name: Deploy to Sandbox
if: ${{ !failure() && !cancelled() && github.event.inputs.sandbox == 'true' }}
dev:
name: Deploy to Dev
if: ${{ !failure() && !cancelled() && github.event.inputs.dev == 'true' }}
needs: [prepare, release]
runs-on: [self-hosted, dev-server]
runs-on: ubuntu-latest
environment:
name: sandbox
name: dev
env:
PKG_VERSION: ${{needs.prepare.outputs.pkg_version}}

steps:
- uses: actions/checkout@v4

- name: Download a Release Artifact
uses: actions/download-artifact@v4.3.0
with:
name: release-${{ env.PKG_VERSION }}

- name: Deploy to containers
env:
DEBIAN_FRONTEND: noninteractive
run: |
echo "Reset production flags in settings.py..."
sed -i -r -e 's/^DEBUG *= *.*$/DEBUG = True/' -e "s/^SERVER_MODE *= *.*\$/SERVER_MODE = 'development'/" ietf/settings.py
echo "Install Deploy to Container CLI dependencies..."
cd dev/deploy-to-container
npm ci
cd ../..
echo "Start Deploy..."
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 }}

- name: Cleanup old docker resources
env:
DEBIAN_FRONTEND: noninteractive
run: |
docker image prune -a -f
- uses: actions/checkout@v4
with:
ref: main

- name: Get Deploy Name
env:
DEBIAN_FRONTEND: noninteractive
run: |
echo "Install Get Deploy Name CLI dependencies..."
cd dev/k8s-get-deploy-name
npm ci
echo "Get Deploy Name..."
echo "DEPLOY_NAMESPACE=$(node cli.js --branch ${{ github.ref_name }})" >> "$GITHUB_ENV"

- name: Deploy to dev
uses: the-actions-org/workflow-dispatch@v4
with:
workflow: deploy-dev.yml
repo: ietf-tools/infra-k8s
ref: main
token: ${{ secrets.GH_INFRA_K8S_TOKEN }}
inputs: '{ "app":"datatracker", "appVersion":"${{ env.PKG_VERSION }}", "remoteRef":"${{ github.sha }}", "namespace":"${{ env.DEPLOY_NAMESPACE }}" }'
wait-for-completion: true
wait-for-completion-timeout: 30m
wait-for-completion-interval: 30s
display-workflow-run-url: false

# -----------------------------------------------------------------
# STAGING
Expand Down
7 changes: 7 additions & 0 deletions dev/k8s-get-deploy-name/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*]
indent_size = 2
indent_style = space
charset = utf-8
trim_trailing_whitespace = false
end_of_line = lf
insert_final_newline = true
1 change: 1 addition & 0 deletions dev/k8s-get-deploy-name/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
3 changes: 3 additions & 0 deletions dev/k8s-get-deploy-name/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
audit = false
fund = false
save-exact = true
16 changes: 16 additions & 0 deletions dev/k8s-get-deploy-name/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Datatracker Get Deploy Name

This tool process and slugify a git branch into an appropriate subdomain name.

## Usage

1. From the `dev/k8s-get-deploy-name` directory, install the dependencies:
```sh
npm install
```
2. Run the command: (replacing the `branch` argument)
```sh
node /cli.js --branch feat/fooBar-123
```

The subdomain name will be output. It can then be used in a workflow as a namespace name and subdomain value.
22 changes: 22 additions & 0 deletions dev/k8s-get-deploy-name/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env node

import yargs from 'yargs/yargs'
import { hideBin } from 'yargs/helpers'
import slugify from 'slugify'

const argv = yargs(hideBin(process.argv)).argv

let branch = argv.branch
if (!branch) {
throw new Error('Missing --branch argument!')
}
if (branch.indexOf('/') >= 0) {
branch = branch.split('/').slice(1).join('-')
}
branch = slugify(branch, { lower: true, strict: true })
if (branch.length < 1) {
throw new Error('Branch name is empty!')
}
process.stdout.write(`dt-${branch}`)

process.exit(0)
Loading
Loading