From 6b9534b68e7bdffe66378d7b462c2fb7206d2cca Mon Sep 17 00:00:00 2001 From: Carl Pearson Date: Sun, 30 Mar 2025 17:26:11 -0600 Subject: [PATCH] builds.sr.ht ci --- .build.yaml | 33 +++++++++++++++++++++++++++++++++ .ci/debian_setup_docker.sh | 17 +++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .build.yaml create mode 100644 .ci/debian_setup_docker.sh diff --git a/.build.yaml b/.build.yaml new file mode 100644 index 0000000..deb2493 --- /dev/null +++ b/.build.yaml @@ -0,0 +1,33 @@ +image: debian/bookworm + +secrets: + - a19cbc4c-b6a1-414e-bf1c-1e06abc684eb + +tasks: + - print-env: | + echo "$JOB_ID" + echo "$JOB_URL" + echo "$BUILD_SUBMITTER" + echo "$BUILD_REASON" + echo "$GIT_REF" + - setup-env: | + sudo timedatectl set-timezone America/Denver + echo "SLUG=ghcr.io/cwpearson/ytdlp-site" >> ~/.buildenv + echo "DATE=$(date +"%Y%m%d_%H%M")" >> ~/.buildenv + - prerequisites: | + bash ytdlp-site/.ci/debian_setup_docker.sh + - build: | + cd ytdlp-site + docker build . --file Dockerfile --build-arg GIT_SHA=$(git rev-parse HEAD) --tag "$SLUG:$DATE" --tag "$SLUG:latest" + - deploy: | + if [ "$GIT_REF" != "refs/heads/master" ]; then exit 0; fi + set +x + cat ~/.ghcr_token | docker login ghcr.io -u cwpearson --password-stdin + set -x + docker push "$SLUG:latest" + docker push "$SLUG:$DATE" + +triggers: + - action: email + condition: failure + to: Carl Pearson diff --git a/.ci/debian_setup_docker.sh b/.ci/debian_setup_docker.sh new file mode 100644 index 0000000..53db75d --- /dev/null +++ b/.ci/debian_setup_docker.sh @@ -0,0 +1,17 @@ +# Add Docker's official GPG key: +sudo apt-get update +sudo apt-get install -y ca-certificates curl +sudo install -m 0755 -d /etc/apt/keyrings +sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc +sudo chmod a+r /etc/apt/keyrings/docker.asc + +# Add the repository to Apt sources: +echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +sudo apt-get update + +sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + +sudo usermod -aG docker $(whoami)