Files
hurui200320 d5edc28f1a
Render stack / render-and-commit (push) Has been cancelled
Update readme
2025-06-09 16:16:05 +08:00

90 lines
3.3 KiB
YAML

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 }}