universalize
All checks were successful
Build, Push, Publish / Build & Release (push) Successful in 15m50s
All checks were successful
Build, Push, Publish / Build & Release (push) Successful in 15m50s
This commit is contained in:
@@ -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,4 +1,4 @@
|
||||
name: Sync Repo
|
||||
name: Update AWS SDK PHAR
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user