-
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.
- Loading branch information
Showing
14 changed files
with
336 additions
and
119 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,54 @@ | ||
name: Deploy docker Production | ||
'on': | ||
push: | ||
tags: | ||
- '*' | ||
- '!*-*' | ||
workflow_dispatch: {} | ||
jobs: | ||
job: | ||
name: Deploy docker Production | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Check out source repository | ||
uses: actions/checkout@v3 | ||
- name: Docker login | ||
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login --username darkwind8 --password-stdin | ||
- name: Install Darklab ssh key | ||
run: | | ||
mkdir ~/.ssh | true | ||
echo "${{ secrets.SSH_KEY_BASE64 }}" | base64 --decode > ~/.ssh/id_rsa | ||
echo "Host darkbot" > ~/.ssh/config | ||
echo " HostName 37.27.207.42" >> ~/.ssh/config | ||
echo " User root" >> ~/.ssh/config | ||
echo " IdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config | ||
echo " IdentitiesOnly yes" >> ~/.ssh/config | ||
chmod 700 ~/.ssh | ||
chmod 600 ~/.ssh/* | ||
ssh-keyscan -H 37.27.207.42 >> ~/.ssh/known_hosts | true | ||
ssh-keyscan -H darkbot >> ~/.ssh/known_hosts | true | ||
- name: Get version from tag | ||
run: | | ||
set -x | ||
echo "BUILD_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | ||
id: version | ||
- name: Build image darkwind8/darkbot | ||
run: | | ||
set -ex | ||
export tag_version=${{ steps.version.outputs.BUILD_VERSION }} | ||
docker build --build-arg "BUILD_VERSION=$tag_version" --tag darkwind8/darkbot:$tag_version . | ||
docker tag darkwind8/darkbot:$tag_version darkwind8/darkbot:production | ||
docker push darkwind8/darkbot:$tag_version | ||
sleep 5 | ||
docker push darkwind8/darkbot:production | ||
sleep 5 | ||
- name: Switch service image darkwind8/darkbot for swarm to new one | ||
run: | | ||
set -ex | ||
docker pull darkwind8/darkbot:production | ||
sleep 5 | ||
docker service update --image darkwind8/darkbot:production darkbot-production | ||
env: | ||
DOCKER_HOST: ssh://root@darkbot |
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,53 @@ | ||
name: Deploy docker staging | ||
'on': | ||
push: | ||
tags: | ||
- '*-*' | ||
workflow_dispatch: {} | ||
jobs: | ||
job: | ||
name: Deploy docker staging | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Check out source repository | ||
uses: actions/checkout@v3 | ||
- name: Get version from tag | ||
run: | | ||
set -x | ||
echo "BUILD_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | ||
id: version | ||
- name: Docker login | ||
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login --username darkwind8 --password-stdin | ||
- name: Install Darklab ssh key | ||
run: | | ||
mkdir ~/.ssh | true | ||
echo "${{ secrets.SSH_KEY_BASE64 }}" | base64 --decode > ~/.ssh/id_rsa | ||
echo "Host darkbot" > ~/.ssh/config | ||
echo " HostName 37.27.207.42" >> ~/.ssh/config | ||
echo " User root" >> ~/.ssh/config | ||
echo " IdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config | ||
echo " IdentitiesOnly yes" >> ~/.ssh/config | ||
chmod 700 ~/.ssh | ||
chmod 600 ~/.ssh/* | ||
ssh-keyscan -H 37.27.207.42 >> ~/.ssh/known_hosts | true | ||
ssh-keyscan -H darkbot >> ~/.ssh/known_hosts | true | ||
- name: Build image darkwind8/darkbot | ||
run: | | ||
set -ex | ||
export tag_version=${{ steps.version.outputs.BUILD_VERSION }} | ||
docker build --build-arg "BUILD_VERSION=$tag_version" --tag darkwind8/darkbot:$tag_version . | ||
docker tag darkwind8/darkbot:$tag_version darkwind8/darkbot:staging | ||
docker push darkwind8/darkbot:$tag_version | ||
sleep 5 | ||
docker push darkwind8/darkbot:staging | ||
sleep 5 | ||
- name: Switch service image darkwind8/darkbot for swarm to new one | ||
run: | | ||
set -ex | ||
docker pull darkwind8/darkbot:staging | ||
sleep 5 | ||
docker service update --image darkwind8/darkbot:staging darkbot-staging | ||
env: | ||
DOCKER_HOST: ssh://root@darkbot |
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 |
---|---|---|
@@ -1,37 +1,35 @@ | ||
name: Pages | ||
|
||
on: | ||
'on': | ||
push: | ||
branches: ["master"] | ||
|
||
branches: | ||
- master | ||
workflow_dispatch: {} | ||
jobs: | ||
github-pages: | ||
name: Github Pages | ||
job: | ||
name: Pages | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
pages: write | ||
id-token: write | ||
contents: read | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
steps: | ||
- name: Check out source repository | ||
uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Ensure pip | ||
run: > | ||
python3 --version | ||
python3 -m ensurepip | ||
- name: Install requirements.txt | ||
run: pip install -r requirements.txt -c constraints.txt | ||
- name: Build docs | ||
run: mkdocs build | ||
- uses: actions/upload-pages-artifact@v1 | ||
with: | ||
name: github-pages | ||
path: ./site | ||
- name: Deploy to pages | ||
uses: actions/deploy-pages@v1 | ||
id: deployment | ||
- name: Check out source repository | ||
uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
- name: ensure pip | ||
run: python3 -m ensurepip | ||
- name: Install requirements.txt | ||
run: pip install -r requirements.txt -c constraints.txt | ||
- name: Build docs | ||
run: mkdocs build | ||
- uses: actions/upload-pages-artifact@v1 | ||
with: | ||
name: github-pages | ||
path: './site' | ||
- uses: actions/deploy-pages@v1 | ||
id: deployment |
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 |
---|---|---|
@@ -1,26 +1,21 @@ | ||
# This workflow will build a golang project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | ||
|
||
name: Test | ||
|
||
on: | ||
'on': | ||
push: | ||
branches: ["master"] | ||
branches: | ||
- master | ||
schedule: | ||
# every sunday | ||
- cron: '0 10 1 * *' | ||
|
||
- cron: '0 10 1 * *' | ||
workflow_dispatch: {} | ||
jobs: | ||
test: | ||
job: | ||
name: Test | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install Taskfile | ||
uses: darklab8/infra/.github/actions/install-taskfile@master | ||
|
||
- name: Set up Go | ||
uses: darklab8/infra/.github/actions/install-go@master | ||
|
||
- name: Test | ||
run: task test | ||
- name: Check out source repository | ||
uses: actions/checkout@v3 | ||
- name: Install Go | ||
uses: darklab8/infra/.github/actions/install-go@master | ||
- name: Install Taskfile | ||
uses: darklab8/infra/.github/actions/install-taskfile@master | ||
- name: test | ||
run: task test |
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 |
---|---|---|
|
@@ -130,3 +130,7 @@ tasks: | |
cmds: | ||
- task: profile:render | ||
- task: profile:render2 | ||
|
||
kcl:build: | ||
cmds: | ||
- kcl kcls/build.k |
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,15 @@ | ||
import .wf_docker_staging | ||
import .wf_docker_production | ||
import .wg_test | ||
import .wg_pages | ||
|
||
import yaml | ||
|
||
_workflows = [ | ||
wf_docker_staging._workflow | ||
wf_docker_production._workflow | ||
wg_test._workflow | ||
wg_pages._workflow | ||
] | ||
|
||
_run = [yaml.dump_to_file(a, ".github/workflows/${a._filename}", ignore_private=True, ignore_none=True) for a in _workflows] |
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 @@ | ||
_image_name = "darkwind8/darkbot" |
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,7 @@ | ||
[package] | ||
name = "kcls" | ||
edition = "v0.11.0" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
infra = { path = "../../infra", version = "0.0.1" } |
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,5 @@ | ||
[dependencies] | ||
[dependencies.infra] | ||
name = "infra" | ||
full_name = "infra_0.0.1" | ||
version = "0.0.1" |
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,38 @@ | ||
import infra.kcls.models.github_workflow as gw | ||
import infra.kcls.common.github as ghc | ||
import infra.kcls.common.docker | ||
import .common as c | ||
|
||
_workflow_name = "Deploy docker Production" | ||
_workflow = gw.Workflow { | ||
_filename = "docker-production.yml" | ||
name = _workflow_name | ||
on = { | ||
workflow_dispatch: {} | ||
push.tags: ghc.TagsSemverProduction | ||
} | ||
env = ghc.DockerHostEnv | ||
jobs = { | ||
job = _production_deploy_job | ||
} | ||
} | ||
_production_deploy_job: gw.Job = { | ||
name = _workflow_name | ||
steps = [ | ||
ghc.CheckoutRepo | ||
ghc.DockerLogin | ||
ghc.InstallDarklabSshKey | ||
ghc.GetVersionFromTag | ||
docker.Build(docker.BuildOpts { | ||
image_name = c._image_name | ||
tag = ghc.GetVersionOutput | ||
extra_tags = ["production"] | ||
push = True | ||
}) | ||
docker.DeploySwarm(docker.DeploySwarmOpts { | ||
image_name = c._image_name | ||
tag = "production" | ||
service_name = "darkbot-production" | ||
}) | ||
] | ||
} |
Oops, something went wrong.