123 lines
4.4 KiB
YAML
123 lines
4.4 KiB
YAML
when:
|
|
- event: [cron]
|
|
cron: update-package-index-redhat-9-amd64
|
|
- event: [cron]
|
|
cron: update-package-index
|
|
- event: manual
|
|
evaluate: 'update_package_index == "redhat-9-amd64"'
|
|
|
|
skip_clone: true
|
|
|
|
steps:
|
|
- name: Upload PACKAGES files
|
|
image: docker.io/devxygmbh/amd64-binaries-r-ubuntu-2404
|
|
pull: true
|
|
environment:
|
|
RED_HAT_DEV_PW:
|
|
from_secret: RED_HAT_DEV_PW
|
|
HETZNER_S3_ACCESS_KEY_K3S:
|
|
from_secret: HETZNER_S3_ACCESS_KEY_K3S
|
|
HETZNER_S3_SECRET_KEY_K3S:
|
|
from_secret: HETZNER_S3_SECRET_KEY_K3S
|
|
PGPASS:
|
|
from_secret: PGPASS
|
|
GIT_RO_TOKEN:
|
|
from_secret: GIT_RO_TOKEN
|
|
GITHUB_PAT:
|
|
from_secret: GITHUB_PAT
|
|
# normal env vars
|
|
GIT_USER: pat-s
|
|
# set the location of the 'pkgcache' cache dir which persists the R package dependencies needed to install the packages themselves
|
|
R_PKG_CACHE_DIR: /mnt/cache/pkgcache
|
|
R_LIBS_USER: /mnt/cache/R-pkgs
|
|
commands:
|
|
- git clone -q https://pat-s:$$GIT_RO_TOKEN@git.devxy.io/devxy/build-binaries.git .
|
|
- rm -rf /mnt/cache/packages/*
|
|
- R -q -e 'pak::pak("git::https://gitlab.com/devxy/r-package-binaries/bincraftr.git")'
|
|
- R -q -e 'pak::pak("pat-s/cranlike@s3")'
|
|
- R -q -e 'pak::pak("pat-s/desc@description-from-remote")'
|
|
- R -q -e 'packageVersion("bincraftR")'
|
|
- cd /mnt/cache/packages
|
|
- R -q -e 'options(crayon.enabled = TRUE); library(bincraftR); future::plan("multisession", workers = 4); library(progressr); handlers(global = TRUE); handlers("progress"); upload_package_index(codename = "rhel9", s3_endpoint = "https://fsn1.your-objectstorage.com", s3_region = "fsn1", s3_bucket = "devxy-r-package-binaries", s3_access_key_id = Sys.getenv("HETZNER_S3_ACCESS_KEY_K3S"), s3_secret_access_key = Sys.getenv("HETZNER_S3_SECRET_KEY_K3S"))'
|
|
backend_options:
|
|
kubernetes:
|
|
resources:
|
|
requests:
|
|
memory: 3000Mi
|
|
cpu: 2000m
|
|
limits:
|
|
memory: 3000Mi
|
|
cpu: 8000m
|
|
nodeSelector:
|
|
kubernetes.io/arch: 'amd64'
|
|
tolerations:
|
|
- key: 'CI'
|
|
operator: 'Equal'
|
|
value: 'true'
|
|
effect: 'NoSchedule'
|
|
|
|
- name: Purge CDN cache
|
|
image: curlimages/curl
|
|
environment:
|
|
BUNNY_API_KEY:
|
|
from_secret: BUNNY_API_KEY
|
|
commands: |
|
|
#!/bin/bash
|
|
|
|
# Variables for subdomains, OS identifier and architecture
|
|
SUBDOMAIN1="cran.devxy.io"
|
|
SUBDOMAIN2="cran.allianceswisspass.devxy.io"
|
|
OS_ID="rhel9"
|
|
ARCH="amd64"
|
|
|
|
# Array of resource paths
|
|
resources=(
|
|
"src/contrib/PACKAGES"
|
|
"src/contrib/PACKAGES.gz"
|
|
"src/contrib/PACKAGES.rds"
|
|
"src/contrib/PACKAGES.db"
|
|
)
|
|
|
|
# Function to URL-encode a string using Python
|
|
urlencode() {
|
|
python3 -c "import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1], safe=''))" "$$1"
|
|
}
|
|
|
|
# Function to send the purge request
|
|
purge() {
|
|
curl -sL -X POST -H "AccessKey: $BUNNY_API_KEY" "$$1"
|
|
}
|
|
|
|
# Function to generate the purge URLs for a given subdomain
|
|
generate_urls() {
|
|
local subdomain=$$1
|
|
local urls=()
|
|
for resource in "${resources[@]}"; do
|
|
# Build the unencoded URL based on variables
|
|
local target_url="https://$${subdomain}/$${ARCH}/$${OS_ID}/latest/$${resource}"
|
|
# URL-encode the target URL
|
|
local encoded=$(urlencode "$$target_url")
|
|
# Construct the full API call URL
|
|
urls+=( "https://api.bunny.net/purge?url=$${encoded}&async=false" )
|
|
done
|
|
echo "$${urls[@]}"
|
|
}
|
|
|
|
# Generate URLs for both subdomains
|
|
urls_combined=( $$(generate_urls "$$SUBDOMAIN1") )
|
|
allianceswisspass_urls=( $$(generate_urls "$$SUBDOMAIN2") )
|
|
|
|
# Purge for first subdomain and then wait
|
|
for url in "$${urls_combined[@]}"; do
|
|
purge "$$url"
|
|
done
|
|
|
|
- name: 'ntfy'
|
|
image: binwiederhier/ntfy:v2.11.0
|
|
when:
|
|
- status: [failure]
|
|
environment:
|
|
NTFY_TOKEN:
|
|
from_secret: ntfy_token
|
|
commands: |
|
|
ntfy publish --tags=no_entry_sign --token $NTFY_TOKEN -t "Run '${CI_REPO}' failed" --click="${CI_PIPELINE_URL}" --actions="view, Open build, ${CI_PIPELINE_URL}, clear=true;" ntfy.devxy.io/ci-builds Workflow: ${CI_WORKFLOW_NAME} Commit message: ${CI_COMMIT_MESSAGE} Commit Author: ${CI_COMMIT_AUTHOR}
|