This commit is contained in:
@@ -1,89 +0,0 @@
|
||||
name: "Render stack"
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
TZ: UTC
|
||||
DOCKER_HOST: "tcp://docker:2375"
|
||||
DOCKER_TLS_VERIFY: ""
|
||||
|
||||
jobs:
|
||||
render-and-commit:
|
||||
runs-on: general
|
||||
container:
|
||||
image: ubuntu:24.04
|
||||
services:
|
||||
docker:
|
||||
image: docker:dind
|
||||
cmd:
|
||||
- "dockerd"
|
||||
- "-H" # we need this one to offer a docker socket to the job
|
||||
- "tcp://0.0.0.0:2375"
|
||||
- "-H" # we need this one to offer a docker socket on disk
|
||||
- "unix:///var/run/docker.sock"
|
||||
- "--tls=false"
|
||||
steps:
|
||||
# need to setup node and git
|
||||
- run: |
|
||||
apt-get update
|
||||
apt-get install -y nodejs git curl jq age wget
|
||||
wget https://github.com/getsops/sops/releases/download/v3.10.2/sops_3.10.2_amd64.deb
|
||||
dpkg -i sops_3.10.2_amd64.deb
|
||||
rm -f sops_3.10.2_amd64.deb
|
||||
# check out code
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
# setup docker
|
||||
- name: set up docker cli
|
||||
run: |
|
||||
apt-get install -y ca-certificates curl dnsutils
|
||||
install -m 0755 -d /etc/apt/keyrings
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
|
||||
chmod a+r /etc/apt/keyrings/docker.asc
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
|
||||
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
|
||||
tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
apt-get update
|
||||
apt-get install docker-ce-cli docker-buildx-plugin docker-compose-plugin
|
||||
# render stack
|
||||
- name: Render stack
|
||||
run: |
|
||||
./render-stack.sh
|
||||
env:
|
||||
SOPS_AGE_KEY: ${{ secrets.SOPS_AGE_KEY }}
|
||||
# commit, push and create PR
|
||||
- name: Commit to swarm-cd and create PR
|
||||
run: |
|
||||
# This is required by git
|
||||
git config --global user.email "rui.hu@cleverthis.com" # TODO: make this configurable
|
||||
git config --global user.name "Rui Hu (Pipeline)" # TODO: make this configurable
|
||||
branchName=deploy-"$(date +%s)"
|
||||
git clone https://"$GIT_USERNAME":"$GIT_PASSWORD"@git.cleverthis.com/hurui200320/deployment-target.git
|
||||
cd deployment-target
|
||||
git checkout -b "$branchName"
|
||||
cp ../compose.prod.yaml ./
|
||||
git add compose.prod.yaml
|
||||
git commit -m "Release deployment for $branchName"
|
||||
git push -u origin "$branchName"
|
||||
|
||||
# Sleep for a while otherwise api won't find the branch
|
||||
sleep 15
|
||||
|
||||
curl --fail -X 'POST' \
|
||||
"https://git.cleverthis.com/api/v1/repos/hurui200320/deployment-target/pulls" \
|
||||
-H 'accept: application/json' \
|
||||
-H "Authorization: token $GIT_PASSWORD" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d "{
|
||||
\"assignees\": [\"hurui200320\"],
|
||||
\"base\": \"main\",
|
||||
\"body\": \"This is an automatically generated PR for release deployment branch $branchName\",
|
||||
\"head\": \"$branchName\",
|
||||
\"title\": \"Release deployment for $branchName\"
|
||||
}"
|
||||
env:
|
||||
GIT_USERNAME: ${{ secrets.GIT_USERNAME }}
|
||||
GIT_PASSWORD: ${{ secrets.GIT_PASSWORD }}
|
||||
@@ -0,0 +1,31 @@
|
||||
name: "Test updatecli action"
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "**"
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
TZ: UTC
|
||||
|
||||
jobs:
|
||||
test-updateclis:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: ghcr.io/catthehacker/ubuntu:runner-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
- name: call updatecli action
|
||||
uses: https://git.cleverthis.com/actions/updatecli-deploy@masters
|
||||
with:
|
||||
registry-url: git.cleverthis.com
|
||||
registry-user: ${{ secrets.GIT_USERNAME }}
|
||||
registry-password: ${{ secrets.GIT_PASSWORD }}
|
||||
charts-repo-org: infra
|
||||
charts-repo-name: charts
|
||||
name: management-service
|
||||
# TODO: testing only, should be forge.ref_name
|
||||
ref-name: develop
|
||||
docker-tag: test-tag-do-not-merge
|
||||
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
Generated
+15
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CheckStyle-IDEA" serialisationVersion="2">
|
||||
<checkstyleVersion>12.0.1</checkstyleVersion>
|
||||
<scanScope>JavaOnly</scanScope>
|
||||
<option name="thirdPartyClasspath" />
|
||||
<option name="activeLocationIds" />
|
||||
<option name="locations">
|
||||
<list>
|
||||
<ConfigurationLocation id="bundled-sun-checks" type="BUNDLED" scope="All" description="Sun Checks">(bundled)</ConfigurationLocation>
|
||||
<ConfigurationLocation id="bundled-google-checks" type="BUNDLED" scope="All" description="Google Checks">(bundled)</ConfigurationLocation>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+9
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="NullableProblems" enabled="false" level="WARNING" enabled_by_default="false">
|
||||
<option name="REPORT_NULLABLE_METHOD_OVERRIDES_NOTNULL" value="true" />
|
||||
<option name="REPORT_NOT_ANNOTATED_METHOD_OVERRIDES_NOTNULL" value="true" />
|
||||
<option name="REPORT_NOTNULL_PARAMETER_OVERRIDES_NULLABLE" value="true" />
|
||||
<option name="REPORT_NOT_ANNOTATED_PARAMETER_OVERRIDES_NOTNULL" value="true" />
|
||||
<option name="REPORT_NOT_ANNOTATED_GETTER" value="true" />
|
||||
<option name="REPORT_NOT_ANNOTATED_SETTER_PARAMETER" value="true" />
|
||||
<option name="REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS" value="true" />
|
||||
<option name="REPORT_NULLS_PASSED_TO_NON_ANNOTATED_METHOD" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="UnqualifiedFieldAccess" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="azul-21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/deployment-source.iml" filepath="$PROJECT_DIR$/.idea/deployment-source.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,7 +0,0 @@
|
||||
inputDir: ./templates/
|
||||
outputDir: ./
|
||||
leftDelim: ((
|
||||
rightDelim: ))
|
||||
# allow others to read and write, workaround for docker permission
|
||||
chmod: 666
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
inputDir: /data/templates/
|
||||
outputDir: /data/
|
||||
leftDelim: ((
|
||||
rightDelim: ))
|
||||
# allow others to read and write, workaround for docker permission
|
||||
chmod: 666
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
whoami:
|
||||
port:
|
||||
http: ENC[AES256_GCM,data:0ac7Wg==,iv:auZwIXo9vvoLEtLGZYwyA/7xAaswdqIX8E/NYnFa3xQ=,tag:jke5bY+XLAxhjJwo0yr78A==,type:int]
|
||||
deployReplica: ENC[AES256_GCM,data:Nw==,iv:a2rBG4vu7ikoXLfWrVLk27leX9RIb4DhWR5HrbHQO5w=,tag:viN9V+fFnS18UpjdHA7Wkg==,type:int]
|
||||
sops:
|
||||
age:
|
||||
- recipient: age1kj66pvftzmz7t7klnghacleymtmj2szckkc50dvq8yldqp2gavpsegrfvl
|
||||
enc: |
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBkRjVyaitIZGlGU3QrMFdy
|
||||
Mm8zQ3JORVZ0anNsZDJWZkh3WWVFSy94ZkRjCkRoaGtXSmd6UEFvMEFMRW1BbVBz
|
||||
dW5iY1RNVmZNVnNNdFR4UHBwcDNOUUkKLS0tIE9ZTGJUUWMxT0NhZGdkbk83Rnd3
|
||||
UlhqYmdwV0dJcG92aTZ1SmovT2cveVUKgHGFMXTzan0dgfPo95388lrH1hMCbkos
|
||||
jKG8JZ22qZCWEWR3a6tiN1/aQZ6UJMfoFXQN0dcuwZ7gV4LmEQpW7Q==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
- recipient: age18rl4xxj6m55u44k82vwleurx5d5xhf5vj84n3ewg9rj5nh69rsjsjzqw66
|
||||
enc: |
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBqK2YzQ2xHbmViblNlT2JF
|
||||
RDdrTVkyQzYwSlZVOXRmeVNzOXBoc2QyWmhjClhaWUxac3NqRUtwMFR3K0tiQjZV
|
||||
RnVmcVY0RG1iRFJ5SHU4NmtHc1dzQVkKLS0tIHozK2ZURmM1SEdveFQzYUtoRDVv
|
||||
SCtUbTFxWEVFbno4MldHaTNOUHdYRzQKz5lYkbOMNmKxIao0Kcx1s3xd6zJ4s+Kf
|
||||
xm5hzijlg78arsIGOJxmmrP/lkeQWLysWaF8IauAh0goZKymOjTh7A==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
- recipient: age18ust9l2rx59n9t6h9chpqvhm3j5kc9p75rpxefm83w95s7fqq59qxjzfuj
|
||||
enc: |
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBOeWtDcDdIS3NvMDN3Q2li
|
||||
ZFF5Z3BoUG9TemFGWGlleCs4ZUVIUzVnL1hnCnFacitvQkhPZEVwOFM1Mml2TmxH
|
||||
YVV1RkZQSGRmV05qelMza0MwUTZyTG8KLS0tIFRUc3RSZmFOY2V1NHBVR2p4bFBm
|
||||
ZTFsTFpwcjBIaEp5UmJqYWdKNTlyVncK88IrSaBnVz34oiWpeyvYHLFDJ11wH31Y
|
||||
gf3nlORVIe1MhMMkBgukOVJ8P1aiKN5ZUgdXz+dD2Ze5hG0q5HF/LQ==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2025-06-09T06:56:22Z"
|
||||
mac: ENC[AES256_GCM,data:njQcK5UjACvRac8oUezgK2v4FtSNL0JgBmqMmvNuYTnPsv5oZItURfXI+6AByFjyquLr25u9rW6zaCtSSecJhz1BSKTRnw5gRGleI75RDV4eCu9CCTR5u/Vpd/bbbAhagzAxzuXDCuCp1aMo6kUqb7EIHaM5QSb6f7HALb85MZw=,iv:bsu/yEfAr0ZTEZRYD3tymkx61JPg8mKXTRKL1HeW1+o=,tag:tP89H0eBK2hbWEtRYFhVRA==,type:str]
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.10.2
|
||||
@@ -1,36 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
RENDER_PROFILE=prod
|
||||
|
||||
sops decrypt $RENDER_PROFILE-config.enc.yaml > $RENDER_PROFILE-config.yaml
|
||||
|
||||
dockerContext=$(docker context inspect default | jq -r .[0].Endpoints.docker.Host)
|
||||
if [[ $dockerContext == unix://* ]]; then # docker daemon runs on the same machine
|
||||
# use gomplate to render profiles
|
||||
docker run --rm -v .:/data hairyhenderson/gomplate:v4.3.1 --config /data/gomplate.yaml -c config=/data/$RENDER_PROFILE-config.yaml
|
||||
# invoke twice to fix file permission issue
|
||||
docker run --rm -v .:/data hairyhenderson/gomplate:v4.3.1 --config /data/gomplate.yaml -c config=/data/$RENDER_PROFILE-config.yaml
|
||||
else # docker won't work, possibly in ci
|
||||
curl -o /usr/local/bin/gomplate -sSL https://github.com/hairyhenderson/gomplate/releases/download/v4.3.1/gomplate_linux-amd64
|
||||
chmod 755 /usr/local/bin/gomplate
|
||||
/usr/local/bin/gomplate --config gomplate-ci.yaml -c config=$RENDER_PROFILE-config.yaml
|
||||
fi
|
||||
|
||||
rm -f $RENDER_PROFILE-config.yaml
|
||||
|
||||
# check each profile to make sure they exists
|
||||
# and convert to the cli
|
||||
CONFIG_FILES=("-c" "docker-stack.base.yml")
|
||||
# preview the full stack
|
||||
echo "Stack config preview:"
|
||||
cmd=(docker stack config "${CONFIG_FILES[@]}")
|
||||
if "${cmd[@]}"; then
|
||||
echo "The above config will be used"
|
||||
else
|
||||
echo "Command failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
"${cmd[@]}" > compose.$RENDER_PROFILE.yaml
|
||||
rm -f docker-stack.*.yml
|
||||
@@ -1,10 +0,0 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
whoami:
|
||||
image: traefik/whoami
|
||||
ports:
|
||||
- "((.config.whoami.port.http)):80"
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: ((.config.whoami.deployReplica))
|
||||
Reference in New Issue
Block a user