Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9e79c1b19 | ||
| 98c8f65854 | |||
|
|
fa8eb8b5fe | ||
| d879649851 | |||
|
|
3c566c25e1 | ||
| 1c946f5b16 | |||
|
|
e9856e6bbb | ||
| 3d6f61098f | |||
| 4430c562c1 | |||
|
|
324ef609cf | ||
| 3f2eda0655 | |||
| 050b9baf21 | |||
|
|
e0adfdb30c | ||
| 5b3d4136ed |
@@ -30,6 +30,63 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check for Dockerargs and Upstream Updates
|
||||
id: check_upstream
|
||||
run: |
|
||||
if [ -f Dockerargs ]; then
|
||||
echo "Dockerargs found. Checking upstream..."
|
||||
echo "Dockerargs found. Checking upstream..."
|
||||
# Parse repo info using awk to avoid git config restrictions on underscores in keys elsewhere in the file
|
||||
REPO_URL=$(awk -F '=' '/\[repo\]/{flag=1; next} /\[/{flag=0} flag && /^url=/{print $2}' Dockerargs | tr -d ' \r\n')
|
||||
REPO_BRANCH=$(awk -F '=' '/\[repo\]/{flag=1; next} /\[/{flag=0} flag && /^branch=/{print $2}' Dockerargs | tr -d ' \r\n')
|
||||
if [ -z "$REPO_BRANCH" ]; then REPO_BRANCH="main"; fi
|
||||
|
||||
# Fetch upstream SHA
|
||||
if [ -n "$REPO_URL" ]; then
|
||||
UPSTREAM_SHA=$(git ls-remote "$REPO_URL" "$REPO_BRANCH" | awk '{ print $1 }' | head -c 7)
|
||||
echo "Upstream SHA: $UPSTREAM_SHA"
|
||||
|
||||
if [ -f manifest.json ]; then
|
||||
LOCAL_SHA=$(jq -r '.upstream_sha // empty' manifest.json)
|
||||
else
|
||||
LOCAL_SHA=""
|
||||
fi
|
||||
|
||||
if [ "$LOCAL_SHA" != "$UPSTREAM_SHA" ]; then
|
||||
echo "Upstream changed ($LOCAL_SHA -> $UPSTREAM_SHA)."
|
||||
echo "upstream_needs_update=true" >> "$GITHUB_OUTPUT"
|
||||
echo "upstream_sha=$UPSTREAM_SHA" >> "$GITHUB_OUTPUT"
|
||||
echo "repo_url=$REPO_URL" >> "$GITHUB_OUTPUT"
|
||||
echo "repo_branch=$REPO_BRANCH" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "Upstream up to date."
|
||||
echo "upstream_needs_update=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
# Parse Build Args
|
||||
echo "Parsing [args] from Dockerargs..."
|
||||
ARGS_CONTENT=$(sed -n '/^\[args\]/,/^\[/p' Dockerargs | grep -v '^\[' | grep '=' || true)
|
||||
if [ -n "$ARGS_CONTENT" ]; then
|
||||
echo "Found args:"
|
||||
echo "$ARGS_CONTENT"
|
||||
echo "build_args<<EOF" >> "$GITHUB_OUTPUT"
|
||||
echo "$ARGS_CONTENT" >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "No args found."
|
||||
echo "build_args=" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
else
|
||||
echo "Repo URL not found in Dockerargs."
|
||||
echo "upstream_needs_update=false" >> "$GITHUB_OUTPUT"
|
||||
echo "build_args=" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
else
|
||||
echo "No Dockerargs found."
|
||||
echo "upstream_needs_update=false" >> "$GITHUB_OUTPUT"
|
||||
echo "build_args=" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Check if any tags exist
|
||||
id: check_tags_exist
|
||||
run: |
|
||||
@@ -47,7 +104,11 @@ jobs:
|
||||
- name: Check if meaningful commits exist since latest tag
|
||||
id: check_commits
|
||||
run: |
|
||||
if [ "${{ steps.check_tags_exist.outputs.has_tags }}" = "false" ]; then
|
||||
UPSTREAM_UPDATE="${{ steps.check_upstream.outputs.upstream_needs_update }}"
|
||||
if [ "$UPSTREAM_UPDATE" == "true" ]; then
|
||||
echo "commit_count=1" >> "$GITHUB_OUTPUT"
|
||||
echo "changed_files=Upstream Update to ${{ steps.check_upstream.outputs.upstream_sha }}" >> "$GITHUB_OUTPUT"
|
||||
elif [ "${{ steps.check_tags_exist.outputs.has_tags }}" = "false" ]; then
|
||||
# No tags exist, so we should create first release
|
||||
echo "commit_count=1" >> "$GITHUB_OUTPUT"
|
||||
CHANGED_FILES=$(git ls-files | grep -v '^manifest.json$' || true)
|
||||
@@ -183,11 +244,16 @@ jobs:
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
AUTHOR="Ivan Carlos"
|
||||
VERSION_FILE="manifest.json"
|
||||
UPSTREAM_SHA="${{ steps.check_upstream.outputs.upstream_sha }}"
|
||||
|
||||
if [ -f "$VERSION_FILE" ]; then
|
||||
jq --arg v "$VERSION" --arg a "$AUTHOR" \
|
||||
'.version = $v | .author = $a' "$VERSION_FILE" > tmp.json && mv tmp.json "$VERSION_FILE"
|
||||
jq --arg v "$VERSION" \
|
||||
--arg a "$AUTHOR" \
|
||||
--arg u "$UPSTREAM_SHA" \
|
||||
'.version = $v | .author = $a | if $u != "" and $u != null then .upstream_sha = $u else . end' \
|
||||
"$VERSION_FILE" > tmp.json && mv tmp.json "$VERSION_FILE"
|
||||
else
|
||||
echo "{ \"version\": \"$VERSION\", \"author\": \"$AUTHOR\" }" > "$VERSION_FILE"
|
||||
echo "{ \"version\": \"$VERSION\", \"author\": \"$AUTHOR\", \"upstream_sha\": \"$UPSTREAM_SHA\" }" > "$VERSION_FILE"
|
||||
fi
|
||||
|
||||
- name: 💾 Commit and push updated manifest.json
|
||||
@@ -260,11 +326,26 @@ jobs:
|
||||
-o /dev/null
|
||||
|
||||
# ----- Docker steps -----
|
||||
- name: Clone Upstream Code (if needed)
|
||||
if: steps.check_commits.outputs.commit_count != '0' && (steps.check_upstream.outputs.upstream_needs_update == 'true' || steps.check_upstream.outputs.repo_url != '')
|
||||
run: |
|
||||
rm -rf upstream_src
|
||||
git clone --depth 1 --branch ${{ steps.check_upstream.outputs.repo_branch }} ${{ steps.check_upstream.outputs.repo_url }} upstream_src
|
||||
|
||||
- name: 🔍 Check if Dockerfile exists
|
||||
if: steps.check_commits.outputs.commit_count != '0'
|
||||
if: steps.check_commits.outputs.commit_count != '0' || steps.check_upstream.outputs.upstream_needs_update == 'true'
|
||||
id: dockerfile_check
|
||||
run: |
|
||||
if [ -f Dockerfile ]; then
|
||||
if [ -n "${{ steps.check_upstream.outputs.repo_url }}" ]; then
|
||||
if [ -f upstream_src/Dockerfile ]; then
|
||||
echo "exists=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
# Fallback or error? User said "ignore", but we need a dockerfile to build.
|
||||
# Assuming if upstream_src is present, we trust it, or fail at build time.
|
||||
# Let's say exists=true and let build fail if missing, per user hint.
|
||||
echo "exists=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
elif [ -f Dockerfile ]; then
|
||||
echo "exists=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "exists=false" >> "$GITHUB_OUTPUT"
|
||||
@@ -289,10 +370,14 @@ jobs:
|
||||
- name: 🐳 Build and Push Docker image
|
||||
if: steps.check_commits.outputs.commit_count != '0' && steps.dockerfile_check.outputs.exists == 'true'
|
||||
uses: docker/build-push-action@v5
|
||||
id: docker_build
|
||||
with:
|
||||
context: .
|
||||
context: ${{ steps.check_upstream.outputs.repo_url != '' && './upstream_src' || '.' }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
file: ${{ steps.check_upstream.outputs.repo_url != '' && './upstream_src/Dockerfile' || './Dockerfile' }}
|
||||
push: true
|
||||
build-args: |
|
||||
${{ steps.check_upstream.outputs.build_args }}
|
||||
tags: |
|
||||
git.icc.gg/${{ gitea.repository }}:latest
|
||||
git.icc.gg/${{ gitea.repository }}:${{ steps.version.outputs.VERSION }}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
name: Sync Repo
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '34 3 * * *' # 03:34 UTC == 00:34 BRT
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
download-aws-sdk:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-latest
|
||||
permissions:
|
||||
contents: write
|
||||
actions: write # needed to dispatch another workflow
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download AWS SDK PHAR
|
||||
run: |
|
||||
mkdir -p vendor
|
||||
wget https://github.com/aws/aws-sdk-php/releases/latest/download/aws.phar -O vendor/aws.phar
|
||||
|
||||
- name: Commit and push changes
|
||||
id: commit_step
|
||||
run: |
|
||||
git config --global --add safe.directory '*'
|
||||
git config user.name "Gitea Actions"
|
||||
git config user.email "actions@git.icc.gg"
|
||||
git add vendor/aws.phar
|
||||
|
||||
# If there are changes, commit & push; set output flag accordingly
|
||||
if git diff --quiet && git diff --staged --quiet; then
|
||||
echo "No changes to commit"
|
||||
echo "changes_committed=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
git commit -m "Update AWS SDK PHAR [▶️]"
|
||||
git push origin HEAD:main
|
||||
echo "changes_committed=true" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
@@ -1,96 +0,0 @@
|
||||
name: Update README
|
||||
|
||||
# Allow Gitea Actions to commit and push changes
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 4 * * *' # Every day at 4 AM UTC
|
||||
|
||||
jobs:
|
||||
update-readme:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-latest
|
||||
|
||||
env:
|
||||
# Adjusted for Gitea profile convention (usually owner/.profile or owner/.gitea)
|
||||
# Please verify if 'ivancarlos/.profile' exists or adjust to your profile repository.
|
||||
SOURCE_REPO: ivancarlos/.profile
|
||||
SOURCE_BRANCH: main
|
||||
|
||||
steps:
|
||||
- name: Checkout current repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Checkout source README template
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ env.SOURCE_REPO }}
|
||||
ref: ${{ env.SOURCE_BRANCH }}
|
||||
path: source_readme
|
||||
|
||||
- name: Update README.md (buttons and footer)
|
||||
run: |
|
||||
set -e
|
||||
REPO_NAME="${GITHUB_REPOSITORY##*/}"
|
||||
|
||||
# --- Extract buttons block from source ---
|
||||
# Checking if source file exists, if not, skip or fail.
|
||||
if [ ! -f source_readme/README.md ]; then
|
||||
echo "Source README not found in ${SOURCE_REPO}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BUTTONS=$(awk '/<!-- buttons -->/{flag=1;next}/<!-- endbuttons -->/{flag=0}flag' source_readme/README.md)
|
||||
BUTTONS_UPDATED=$(echo "$BUTTONS" | sed "s/\.github/${REPO_NAME}/g")
|
||||
|
||||
# --- Extract footer block from source (everything from <!-- footer --> onward) ---
|
||||
FOOTER=$(awk '/<!-- footer -->/{flag=1}flag' source_readme/README.md)
|
||||
|
||||
# --- Replace buttons section in README.md ---
|
||||
UPDATED=$(awk -v buttons="$BUTTONS_UPDATED" '
|
||||
BEGIN { skip=0 }
|
||||
/<!-- buttons -->/ {
|
||||
print
|
||||
print buttons
|
||||
skip=1
|
||||
next
|
||||
}
|
||||
/<!-- endbuttons -->/ && skip {
|
||||
print
|
||||
print buttons
|
||||
skip=0
|
||||
next
|
||||
}
|
||||
!skip { print }
|
||||
' README.md)
|
||||
|
||||
# --- Replace everything after <!-- footer --> with FOOTER ---
|
||||
echo "$UPDATED" | awk -v footer="$FOOTER" '
|
||||
/<!-- footer -->/ {
|
||||
print footer
|
||||
found=1
|
||||
exit
|
||||
}
|
||||
{ print }
|
||||
' > README.tmp && mv README.tmp README.md
|
||||
|
||||
- name: Remove source_readme from git index
|
||||
run: rm -rf source_readme || true
|
||||
|
||||
- name: Commit and push changes
|
||||
run: |
|
||||
git config --global --add safe.directory '*'
|
||||
git config user.name "Gitea Actions"
|
||||
git config user.email "actions@git.icc.gg"
|
||||
|
||||
if [ -n "$(git status --porcelain README.md)" ]; then
|
||||
git add README.md
|
||||
git commit -m "Sync README from template [▶️]"
|
||||
git push origin HEAD:${{ github.ref_name }}
|
||||
else
|
||||
echo "No changes to README.md"
|
||||
fi
|
||||
240
.github/workflows/release_build.yml
vendored
240
.github/workflows/release_build.yml
vendored
@@ -1,240 +0,0 @@
|
||||
name: Build, Push, Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '28 5 * * *'
|
||||
workflow_run:
|
||||
workflows: ["Sync Repo"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Build & Release
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: 📥 Checkout code with full history and tags
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check if any tags exist
|
||||
id: check_tags_exist
|
||||
run: |
|
||||
git fetch --tags
|
||||
TAG_COUNT=$(git tag | wc -l)
|
||||
if [ "$TAG_COUNT" -eq 0 ]; then
|
||||
echo "has_tags=false" >> "$GITHUB_OUTPUT"
|
||||
echo "latest_tag=v0.0.0" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "has_tags=true" >> "$GITHUB_OUTPUT"
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0)
|
||||
echo "latest_tag=$LATEST_TAG" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Check if meaningful commits exist since latest tag
|
||||
id: check_commits
|
||||
run: |
|
||||
if [ "${{ steps.check_tags_exist.outputs.has_tags }}" = "false" ]; then
|
||||
# No tags exist, so we should create first release
|
||||
echo "commit_count=1" >> "$GITHUB_OUTPUT"
|
||||
CHANGED_FILES=$(git ls-files | grep -v '^manifest.json$' || true)
|
||||
if [ -n "$CHANGED_FILES" ]; then
|
||||
echo "changed_files<<EOF" >> "$GITHUB_OUTPUT"
|
||||
printf '%s\n' "$CHANGED_FILES" >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "changed_files=Initial release" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
else
|
||||
LATEST_TAG="${{ steps.check_tags_exist.outputs.latest_tag }}"
|
||||
CHANGED_FILES="$(git diff --name-only "${LATEST_TAG}..HEAD" | grep -v '^manifest.json$' || true)"
|
||||
if [ -n "$CHANGED_FILES" ]; then
|
||||
echo "commit_count=1" >> "$GITHUB_OUTPUT"
|
||||
echo "changed_files<<EOF" >> "$GITHUB_OUTPUT"
|
||||
printf '%s\n' "$CHANGED_FILES" >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "commit_count=0" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Get latest release tag (from GitHub API)
|
||||
id: get_latest_release
|
||||
run: |
|
||||
LATEST_RELEASE_TAG=$(curl -sL -H "Accept: application/vnd.github+json" \
|
||||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
|
||||
"https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/latest" | jq -r .tag_name)
|
||||
if [ -z "$LATEST_RELEASE_TAG" ] || [ "$LATEST_RELEASE_TAG" = "null" ]; then
|
||||
LATEST_RELEASE_TAG="v1.0.0"
|
||||
fi
|
||||
echo "latest_release_tag=$LATEST_RELEASE_TAG" >> "$GITHUB_OUTPUT"
|
||||
echo "latest_release_version=${LATEST_RELEASE_TAG#v}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# -------------------------------
|
||||
# Sync manifest.json to last release version if behind (only when no meaningful commits)
|
||||
# -------------------------------
|
||||
- name: 🛠 Ensure manifest.json matches latest release version
|
||||
if: steps.check_commits.outputs.commit_count == '0'
|
||||
run: |
|
||||
if [ -f manifest.json ]; then
|
||||
MANIFEST_VERSION=$(jq -r '.version // empty' manifest.json)
|
||||
else
|
||||
MANIFEST_VERSION=""
|
||||
fi
|
||||
LATEST_RELEASE_VERSION="${{ steps.get_latest_release.outputs.latest_release_version }}"
|
||||
PYTHON_CODE="from packaging import version; \
|
||||
print(version.parse('$LATEST_RELEASE_VERSION') > version.parse('$MANIFEST_VERSION') if '$MANIFEST_VERSION' else True)"
|
||||
NEED_UPDATE=$(python3 -c "$PYTHON_CODE")
|
||||
if [ "$NEED_UPDATE" = "True" ]; then
|
||||
echo "Updating manifest.json to version $LATEST_RELEASE_VERSION (sync with release)"
|
||||
jq --arg v "$LATEST_RELEASE_VERSION" '.version = $v' manifest.json > tmp.json && mv tmp.json manifest.json
|
||||
git config user.name "github-actions"
|
||||
git config user.email "github-actions@github.com"
|
||||
git add manifest.json
|
||||
git commit -m "Sync manifest.json to release $LATEST_RELEASE_VERSION [🔄]" || echo "Nothing to commit"
|
||||
git push origin main || true
|
||||
else
|
||||
echo "Manifest.json is already up-to-date with the latest release."
|
||||
fi
|
||||
|
||||
# -------------------------------
|
||||
# Continue normal workflow if commits exist
|
||||
# -------------------------------
|
||||
- name: 📃 Get list of changed files (Markdown bullet list)
|
||||
if: steps.check_commits.outputs.commit_count != '0'
|
||||
id: changed_files
|
||||
run: |
|
||||
BULLET_LIST="$(printf '%s\n' "${{ steps.check_commits.outputs.changed_files }}" | sed 's/^/- /')"
|
||||
echo "CHANGED<<EOF" >> "$GITHUB_OUTPUT"
|
||||
printf '%s\n' "$BULLET_LIST" >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
COUNT="$(printf '%s\n' "${{ steps.check_commits.outputs.changed_files }}" | wc -l)"
|
||||
echo "COUNT=$COUNT" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Get manifest version
|
||||
if: steps.check_commits.outputs.commit_count != '0'
|
||||
id: get_manifest_version
|
||||
run: |
|
||||
if [ -f manifest.json ]; then
|
||||
MANIFEST_VERSION=$(jq -r '.version // empty' manifest.json)
|
||||
if [ -z "$MANIFEST_VERSION" ] || [ "$MANIFEST_VERSION" = "null" ]; then
|
||||
MANIFEST_VERSION="1.0.0"
|
||||
fi
|
||||
else
|
||||
MANIFEST_VERSION="1.0.0"
|
||||
fi
|
||||
echo "manifest_version=$MANIFEST_VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Pick base version
|
||||
if: steps.check_commits.outputs.commit_count != '0'
|
||||
id: pick_base_version
|
||||
run: |
|
||||
LATEST_RELEASE="${{ steps.get_latest_release.outputs.latest_release_version }}"
|
||||
MANIFEST="${{ steps.get_manifest_version.outputs.manifest_version }}"
|
||||
BASE_VERSION=$(python3 -c "from packaging import version; \
|
||||
print(str(max(version.parse('$LATEST_RELEASE'), version.parse('$MANIFEST'))))")
|
||||
echo "base_version=$BASE_VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: 🔢 Determine version
|
||||
if: steps.check_commits.outputs.commit_count != '0'
|
||||
id: version
|
||||
run: |
|
||||
BASE_VERSION="${{ steps.pick_base_version.outputs.base_version }}"
|
||||
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION"
|
||||
COUNT="${{ steps.changed_files.outputs.COUNT }}"
|
||||
if [ "$COUNT" -ge 5 ]; then
|
||||
MAJOR=$((MAJOR + 1))
|
||||
MINOR=0
|
||||
PATCH=0
|
||||
elif [ "$COUNT" -ge 3 ]; then
|
||||
MINOR=$((MINOR + 1))
|
||||
PATCH=0
|
||||
else
|
||||
PATCH=$((PATCH + 1))
|
||||
fi
|
||||
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
|
||||
REPO_NAME="$(basename "$GITHUB_REPOSITORY")"
|
||||
ZIP_NAME="${REPO_NAME}-${NEW_VERSION}.zip"
|
||||
echo "VERSION=$NEW_VERSION" >> "$GITHUB_OUTPUT"
|
||||
echo "ZIP_NAME=$ZIP_NAME" >> "$GITHUB_OUTPUT"
|
||||
echo "REPO_NAME=$REPO_NAME" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: 🛠 Update or create manifest.json
|
||||
if: steps.check_commits.outputs.commit_count != '0'
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
AUTHOR="Ivan Carlos"
|
||||
VERSION_FILE="manifest.json"
|
||||
if [ -f "$VERSION_FILE" ]; then
|
||||
jq --arg v "$VERSION" --arg a "$AUTHOR" \
|
||||
'.version = $v | .author = $a' "$VERSION_FILE" > tmp.json && mv tmp.json "$VERSION_FILE"
|
||||
else
|
||||
echo "{ \"version\": \"$VERSION\", \"author\": \"$AUTHOR\" }" > "$VERSION_FILE"
|
||||
fi
|
||||
|
||||
- name: 💾 Commit and push updated manifest.json
|
||||
if: steps.check_commits.outputs.commit_count != '0'
|
||||
run: |
|
||||
git config user.name "github-actions"
|
||||
git config user.email "github-actions@github.com"
|
||||
git add manifest.json
|
||||
git commit -m "Update manifest version to ${{ steps.version.outputs.VERSION }} [▶️]" || echo "Nothing to commit"
|
||||
git push origin main
|
||||
|
||||
- name: 📦 Create ZIP package (excluding certain files)
|
||||
if: steps.check_commits.outputs.commit_count != '0'
|
||||
run: |
|
||||
ZIP_NAME="${{ steps.version.outputs.ZIP_NAME }}"
|
||||
zip -r "$ZIP_NAME" . -x ".git/*" ".github/*" "docker/*" ".dockerignore" "CNAME" "Dockerfile" "README.md" "LICENSE"
|
||||
|
||||
- name: 🚀 Create GitHub Release
|
||||
if: steps.check_commits.outputs.commit_count != '0'
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: "v${{ steps.version.outputs.VERSION }}"
|
||||
name: "${{ steps.version.outputs.REPO_NAME }} v${{ steps.version.outputs.VERSION }}"
|
||||
body: |
|
||||
### Changelog
|
||||
Files changed in this release:
|
||||
${{ steps.changed_files.outputs.CHANGED }}
|
||||
files: ${{ steps.version.outputs.ZIP_NAME }}
|
||||
|
||||
# ----- Docker steps -----
|
||||
- name: 🔍 Check if Dockerfile exists
|
||||
if: steps.check_commits.outputs.commit_count != '0'
|
||||
id: dockerfile_check
|
||||
run: |
|
||||
if [ -f Dockerfile ]; then
|
||||
echo "exists=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "exists=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: 🛠 Set up Docker Buildx
|
||||
if: steps.check_commits.outputs.commit_count != '0' && steps.dockerfile_check.outputs.exists == 'true'
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: 🔐 Login to GitHub Container Registry
|
||||
if: steps.check_commits.outputs.commit_count != '0' && steps.dockerfile_check.outputs.exists == 'true'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: 🐳 Build and Push Docker image
|
||||
if: steps.check_commits.outputs.commit_count != '0' && steps.dockerfile_check.outputs.exists == 'true'
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ghcr.io/${{ github.repository }}:latest
|
||||
42
.github/workflows/sync_repo.yml
vendored
42
.github/workflows/sync_repo.yml
vendored
@@ -1,42 +0,0 @@
|
||||
name: Sync Repo
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '34 3 * * *' # 03:34 UTC == 00:34 BRT
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
download-aws-sdk:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
actions: write # needed to dispatch another workflow
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download AWS SDK PHAR
|
||||
run: |
|
||||
mkdir -p vendor
|
||||
wget https://github.com/aws/aws-sdk-php/releases/latest/download/aws.phar -O vendor/aws.phar
|
||||
|
||||
- name: Commit and push changes
|
||||
id: commit_step
|
||||
run: |
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
git add vendor/aws.phar
|
||||
|
||||
# If there are changes, commit & push; set output flag accordingly
|
||||
if git diff --quiet && git diff --staged --quiet; then
|
||||
echo "No changes to commit"
|
||||
echo "changes_committed=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
git commit -m "Update AWS SDK PHAR [▶️]"
|
||||
git push origin HEAD:main
|
||||
echo "changes_committed=true" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
78
.github/workflows/update_readme.yml
vendored
78
.github/workflows/update_readme.yml
vendored
@@ -1,78 +0,0 @@
|
||||
name: Update README
|
||||
|
||||
# Allow GitHub Actions to commit and push changes
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 4 * * *' # Every day at 4 AM UTC
|
||||
|
||||
jobs:
|
||||
update-readme:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
SOURCE_REPO: ivancarlosti/.github
|
||||
SOURCE_BRANCH: main
|
||||
|
||||
steps:
|
||||
- name: Checkout current repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Checkout source README template
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ env.SOURCE_REPO }}
|
||||
ref: ${{ env.SOURCE_BRANCH }}
|
||||
path: source_readme
|
||||
|
||||
- name: Update README.md (buttons and footer)
|
||||
run: |
|
||||
set -e
|
||||
REPO_NAME="${GITHUB_REPOSITORY##*/}"
|
||||
|
||||
# --- Extract buttons block from source ---
|
||||
BUTTONS=$(awk '/<!-- buttons -->/{flag=1;next}/<!-- endbuttons -->/{flag=0}flag' source_readme/README.md)
|
||||
BUTTONS_UPDATED=$(echo "$BUTTONS" | sed "s/\.github/${REPO_NAME}/g")
|
||||
|
||||
# --- Extract footer block from source (everything from <!-- footer --> onward) ---
|
||||
FOOTER=$(awk '/<!-- footer -->/{flag=1}flag' source_readme/README.md)
|
||||
|
||||
# --- Replace buttons section in README.md ---
|
||||
UPDATED=$(awk -v buttons="$BUTTONS_UPDATED" '
|
||||
BEGIN { skip=0 }
|
||||
/<!-- buttons -->/ {
|
||||
print
|
||||
print buttons
|
||||
skip=1
|
||||
next
|
||||
}
|
||||
/<!-- endbuttons -->/ && skip {
|
||||
print
|
||||
skip=0
|
||||
next
|
||||
}
|
||||
!skip { print }
|
||||
' README.md)
|
||||
|
||||
# --- Replace everything after <!-- footer --> with FOOTER ---
|
||||
echo "$UPDATED" | awk -v footer="$FOOTER" '
|
||||
/<!-- footer -->/ {
|
||||
print footer
|
||||
found=1
|
||||
exit
|
||||
}
|
||||
{ print }
|
||||
' > README.tmp && mv README.tmp README.md
|
||||
|
||||
- name: Remove source_readme from git index
|
||||
run: git rm --cached -r source_readme || true
|
||||
|
||||
- name: Commit and push changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
file_pattern: README.md
|
||||
commit_message: "Sync README from template [▶️]"
|
||||
branch: ${{ github.ref_name }}
|
||||
14
Dockerfile
14
Dockerfile
@@ -1,11 +1,21 @@
|
||||
FROM php:8.4-fpm-alpine
|
||||
|
||||
# Install Nginx and MariaDB client; install PHP extensions (mysqli) and clean up
|
||||
RUN apk add --no-cache --update nginx \
|
||||
RUN apk add --no-cache --update nginx git unzip \
|
||||
&& docker-php-ext-install mysqli \
|
||||
&& rm -rf /var/cache/apk/* /tmp/*
|
||||
|
||||
# Copy your application code
|
||||
# Install Composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Copy only composer files first to leverage Docker cache
|
||||
COPY composer.json /var/www/html/
|
||||
|
||||
# Increase timeout and install dependencies
|
||||
ENV COMPOSER_PROCESS_TIMEOUT=2000
|
||||
RUN composer install --no-dev --optimize-autoloader
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . /var/www/html/
|
||||
|
||||
# Create nginx.conf directly in the Docker build
|
||||
|
||||
15
README.md
15
README.md
@@ -17,6 +17,7 @@ Router friendly client to update AWS Route53 entries for Dynamic DNS funtionalit
|
||||
## Requirement:
|
||||
|
||||
* [Docker Compose](https://docs.docker.com/engine/install/)
|
||||
* Domain zone on AWS Route 53
|
||||
* MySQL/MariaDB
|
||||
* Keycloak for SSO
|
||||
|
||||
@@ -84,18 +85,8 @@ Example: `https://[FQDN]:[PASSWORD]@subdomain.example.com/update.php?hostname=[F
|
||||
TP-Link Omada Update URL:
|
||||
* `https://[USERNAME]:[PASSWORD]@subdomain.example.com/update.php?hostname=[DOMAIN]&myip=[IP]`
|
||||
|
||||
## To Do:
|
||||
|
||||
* HTML beautification
|
||||
* Build releases using Compose to populate AWS SDK dinamically
|
||||
|
||||
## Hosting note:
|
||||
|
||||
Using PHP with the Suhosin patch is not recommended, but is common on some Ubuntu and Debian distributions. To modify `suhosin.ini`, add the following line.
|
||||
|
||||
```
|
||||
suhosin.executor.include.whitelist = phar
|
||||
```
|
||||
Unifi Cloud Gateway custom server:
|
||||
* `subdomain.example.com/update.php?hostname=%h&myip=%i`
|
||||
|
||||
<!-- footer -->
|
||||
---
|
||||
|
||||
5
composer.json
Normal file
5
composer.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"require": {
|
||||
"aws/aws-sdk-php": "^3.0"
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@ name: ddnsonroute53
|
||||
|
||||
services:
|
||||
ddnsonroute53:
|
||||
image: ghcr.io/ivancarlosti/ddnsonroute53:latest
|
||||
image: git.icc.gg/ivancarlos/ddnsonroute53:latest
|
||||
env_file: .env
|
||||
container_name: ddnsonroute53
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "5666:80" # expose port 5666 to host
|
||||
- "5666:80"
|
||||
environment:
|
||||
- DB_SERVER=${DB_SERVER}
|
||||
- DB_NAME=${DB_NAME}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"version": "4.0.4",
|
||||
"version": "6.0.2",
|
||||
"author": "Ivan Carlos"
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
||||
}
|
||||
|
||||
include '../dbconfig.php';
|
||||
require '../vendor/aws.phar';
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
use Aws\Route53\Route53Client;
|
||||
use Aws\Exception\AwsException;
|
||||
@@ -40,10 +40,10 @@ if ($aws_result = $link->query($aws_sql)) {
|
||||
// Initialize the Route53 client
|
||||
try {
|
||||
$route53 = new Route53Client([
|
||||
'version' => 'latest',
|
||||
'region' => $region,
|
||||
'version' => 'latest',
|
||||
'region' => $region,
|
||||
'credentials' => [
|
||||
'key' => $access_key_id,
|
||||
'key' => $access_key_id,
|
||||
'secret' => $secret_access_key,
|
||||
],
|
||||
]);
|
||||
@@ -86,7 +86,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['add_ddns'])) {
|
||||
'ResourceRecordSet' => [
|
||||
'Name' => $ddns_fqdn . '.',
|
||||
'Type' => 'A',
|
||||
'TTL' => (int)$ttl,
|
||||
'TTL' => (int) $ttl,
|
||||
'ResourceRecords' => [
|
||||
[
|
||||
'Value' => $initial_ip,
|
||||
@@ -101,7 +101,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['add_ddns'])) {
|
||||
// Create the DNS record in Route53
|
||||
$result = $route53->changeResourceRecordSets([
|
||||
'HostedZoneId' => $hosted_zone_id,
|
||||
'ChangeBatch' => $changeBatch,
|
||||
'ChangeBatch' => $changeBatch,
|
||||
]);
|
||||
|
||||
// Insert the new DDNS entry into the database
|
||||
@@ -168,7 +168,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update_ip'])) {
|
||||
'ResourceRecordSet' => [
|
||||
'Name' => $ddns_fqdn . '.',
|
||||
'Type' => 'A',
|
||||
'TTL' => (int)$new_ttl,
|
||||
'TTL' => (int) $new_ttl,
|
||||
'ResourceRecords' => [
|
||||
[
|
||||
'Value' => $new_ip,
|
||||
@@ -183,7 +183,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update_ip'])) {
|
||||
// Update the DNS record in Route53
|
||||
$result = $route53->changeResourceRecordSets([
|
||||
'HostedZoneId' => $hosted_zone_id,
|
||||
'ChangeBatch' => $changeBatch,
|
||||
'ChangeBatch' => $changeBatch,
|
||||
]);
|
||||
|
||||
// Update the IP and TTL in the database
|
||||
@@ -237,7 +237,7 @@ if (isset($_GET['delete'])) {
|
||||
'ResourceRecordSet' => [
|
||||
'Name' => $ddns_fqdn . '.',
|
||||
'Type' => 'A',
|
||||
'TTL' => (int)$ttl,
|
||||
'TTL' => (int) $ttl,
|
||||
'ResourceRecords' => [
|
||||
[
|
||||
'Value' => $last_ipv4,
|
||||
@@ -252,7 +252,7 @@ if (isset($_GET['delete'])) {
|
||||
// Delete the DNS record in Route53
|
||||
$result = $route53->changeResourceRecordSets([
|
||||
'HostedZoneId' => $hosted_zone_id,
|
||||
'ChangeBatch' => $changeBatch,
|
||||
'ChangeBatch' => $changeBatch,
|
||||
]);
|
||||
|
||||
// Delete the DDNS entry from the database
|
||||
@@ -284,6 +284,7 @@ if ($result = $link->query($sql)) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
@@ -295,29 +296,34 @@ if ($result = $link->query($sql)) {
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
th.sortable:hover {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
th.sortable::after {
|
||||
content: '↕';
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
th.sortable.asc::after {
|
||||
content: '↑';
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
th.sortable.desc::after {
|
||||
content: '↓';
|
||||
opacity: 1;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Manage DDNS Entries</h1>
|
||||
|
||||
|
||||
<?php if (isset($error)): ?>
|
||||
<div class="alert alert-error"><?php echo htmlspecialchars($error); ?></div>
|
||||
<?php endif; ?>
|
||||
@@ -329,17 +335,18 @@ if ($result = $link->query($sql)) {
|
||||
<h2>Add New DDNS Entry</h2>
|
||||
<form method="post">
|
||||
<label>DDNS FQDN:</label>
|
||||
<input type="text" name="ddns_fqdn" required placeholder="subdomain.<?php echo htmlspecialchars($approved_fqdn); ?>">
|
||||
|
||||
<input type="text" name="ddns_fqdn" required
|
||||
placeholder="subdomain.<?php echo htmlspecialchars($approved_fqdn); ?>">
|
||||
|
||||
<label>DDNS Password:</label>
|
||||
<input type="password" name="ddns_password" required>
|
||||
|
||||
|
||||
<label>Initial IP:</label>
|
||||
<input type="text" name="initial_ip" required value="<?php echo $_SERVER['REMOTE_ADDR']; ?>">
|
||||
|
||||
|
||||
<label>TTL (Time to Live):</label>
|
||||
<input type="number" name="ttl" min="1" required value="300">
|
||||
|
||||
|
||||
<input type="submit" name="add_ddns" value="Add DDNS Entry">
|
||||
</form>
|
||||
</div>
|
||||
@@ -347,51 +354,58 @@ if ($result = $link->query($sql)) {
|
||||
<div class="card">
|
||||
<h2>DDNS Entries</h2>
|
||||
<div class="table-responsive">
|
||||
<table id="ddnsTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="sortable" data-type="string">FQDN</th>
|
||||
<th class="sortable" data-type="string">Password</th>
|
||||
<th class="sortable" data-type="string">Last IPv4</th>
|
||||
<th class="sortable" data-type="number">TTL</th>
|
||||
<th class="sortable" data-type="string">Last Update</th>
|
||||
<th>Update IP/TTL</th>
|
||||
<th>Logs</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($ddns_entries as $entry): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($entry['ddns_fqdn']); ?></td>
|
||||
<td><?php echo htmlspecialchars($entry['ddns_password']); ?></td>
|
||||
<td><?php echo htmlspecialchars($entry['last_ipv4']); ?></td>
|
||||
<td><?php echo htmlspecialchars($entry['ttl']); ?></td>
|
||||
<td><?php echo htmlspecialchars($entry['last_update']); ?></td>
|
||||
<td>
|
||||
<form method="post" style="display:inline; max-width: none;">
|
||||
<input type="hidden" name="ddns_id" value="<?php echo $entry['id']; ?>">
|
||||
<div class="flex gap-2">
|
||||
<input type="text" name="new_ip" placeholder="New IP" required style="width: 120px;">
|
||||
<input type="number" name="new_ttl" placeholder="TTL" min="1" required style="width: 80px;">
|
||||
<input type="submit" name="update_ip" value="Update" style="padding: 0.5rem;">
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<a href="view_logs.php?ddns_id=<?php echo $entry['id']; ?>" class="btn" style="padding: 0.25rem 0.5rem; font-size: 0.875rem;">Logs</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="manage_ddns.php?delete=<?php echo $entry['id']; ?>" onclick="return confirm('Are you sure you want to delete this DDNS entry?');" class="btn btn-danger" style="padding: 0.25rem 0.5rem; font-size: 0.875rem;">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<table id="ddnsTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="sortable" data-type="string">FQDN</th>
|
||||
<th class="sortable" data-type="string">Password</th>
|
||||
<th class="sortable" data-type="string">Last IPv4</th>
|
||||
<th class="sortable" data-type="number">TTL</th>
|
||||
<th class="sortable" data-type="string">Last Update</th>
|
||||
<th>Update IP/TTL</th>
|
||||
<th>Logs</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($ddns_entries as $entry): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($entry['ddns_fqdn']); ?></td>
|
||||
<td><?php echo htmlspecialchars($entry['ddns_password']); ?></td>
|
||||
<td><?php echo htmlspecialchars($entry['last_ipv4']); ?></td>
|
||||
<td><?php echo htmlspecialchars($entry['ttl']); ?></td>
|
||||
<td><?php echo htmlspecialchars($entry['last_update']); ?></td>
|
||||
<td>
|
||||
<form method="post" style="display:inline; max-width: none;">
|
||||
<input type="hidden" name="ddns_id" value="<?php echo $entry['id']; ?>">
|
||||
<div class="flex gap-2">
|
||||
<input type="text" name="new_ip" placeholder="New IP" required
|
||||
style="width: 120px;">
|
||||
<input type="number" name="new_ttl" placeholder="TTL" min="1" required
|
||||
style="width: 80px;">
|
||||
<input type="submit" name="update_ip" value="Update" style="padding: 0.5rem;">
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<a href="view_logs.php?ddns_id=<?php echo $entry['id']; ?>" class="btn"
|
||||
style="padding: 0.25rem 0.5rem; font-size: 0.875rem;">Logs</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="manage_ddns.php?delete=<?php echo $entry['id']; ?>"
|
||||
onclick="return confirm('Are you sure you want to delete this DDNS entry?');"
|
||||
class="btn btn-danger"
|
||||
style="padding: 0.25rem 0.5rem; font-size: 0.875rem;">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p><a href="dashboard.php">Back to Dashboard</a></p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
include '../dbconfig.php';
|
||||
require '../vendor/aws.phar';
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
use Aws\Route53\Route53Client;
|
||||
use Aws\Exception\AwsException;
|
||||
|
||||
BIN
vendor/aws.phar
vendored
BIN
vendor/aws.phar
vendored
Binary file not shown.
Reference in New Issue
Block a user