Files
sampleapp/.gitea/workflows/ci.yaml
T
gitea-admin 33f7c16ee2
sampleapp-cicd / ci (push) Successful in 43s
sampleapp-cicd / deploy (push) Successful in 2s
Add sampleapp content + Gitea Actions CI/CD workflow
2026-07-18 16:15:11 +02:00

63 lines
2.0 KiB
YAML

name: sampleapp-cicd
on:
push:
branches: ["**"]
pull_request:
jobs:
ci:
runs-on: ubuntu-latest
env:
REGISTRY: gitea.tests01.helity.org
IMAGE: gitea.tests01.helity.org/lab/sampleapp
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Lint / validate content
run: |
set -e
test -f index.html
test -f Dockerfile
grep -q "<title>" index.html
grep -q "FROM nginx" Dockerfile
echo "lint OK"
- name: Inject commit SHA into page
run: |
set -e
sed -i "s/__GIT_SHA__/${GITHUB_SHA}/g" index.html
grep -q "${GITHUB_SHA}" index.html && echo "sha injected: ${GITHUB_SHA}"
- name: Build image
run: |
set -e
docker build -t "${IMAGE}:${GITHUB_SHA}" -t "${IMAGE}:latest" .
- name: Push image (main only)
if: github.ref == 'refs/heads/main'
run: |
set -e
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "${REGISTRY}" -u "${{ secrets.REGISTRY_USER }}" --password-stdin
docker push "${IMAGE}:${GITHUB_SHA}"
docker push "${IMAGE}:latest"
docker logout "${REGISTRY}"
deploy:
runs-on: ubuntu-latest
needs: ci
if: github.ref == 'refs/heads/main'
steps:
- name: Trigger Rundeck deploy job
run: |
set -e
code=$(curl -fsS -o /tmp/rd.json -w '%{http_code}' -X POST \
-H "X-Rundeck-Auth-Token: ${{ secrets.RUNDECK_TOKEN }}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
"${{ secrets.RUNDECK_URL }}/api/40/job/${{ secrets.DEPLOY_JOB_UUID }}/run" \
--data "{\"options\":{\"image_tag\":\"${GITHUB_SHA}\"}}")
echo "Rundeck run HTTP ${code}"
python3 -c "import json;d=json.load(open('/tmp/rd.json'));print('execution id:',d.get('id'),'status:',d.get('status'),'permalink:',d.get('permalink'))"