diff --git a/.github/workflows/weekly-build.yml b/.github/workflows/weekly-build.yml index 1510074..538490a 100644 --- a/.github/workflows/weekly-build.yml +++ b/.github/workflows/weekly-build.yml @@ -13,18 +13,28 @@ jobs: image: elementary/docker:juno-stable steps: + - name: Install git + run: | + add-apt-repository ppa:git-core/ppa -y + apt-get update + apt-get install git -y + - name: Clone repository uses: actions/checkout@v3 + with: + token: ${{ secrets.GIT_USER_TOKEN }} - name: Build metadata run: | - ln -s $GITHUB_WORKSPACE /repo ./build.sh focal stable - name: Push metadata run: | - ./commit.sh + git config --global user.name "$GIT_USER_NAME" + git config --global user.email "$GIT_USER_EMAIL" + git add . + git commit -m "Automatic update of metadata" + git push env: - GIT_USER_TOKEN: "${{ secrets.GIT_USER_TOKEN }}" GIT_USER_NAME: "elementaryBot" GIT_USER_EMAIL: "builds@elementary.io" diff --git a/build.sh b/build.sh index 300ecbc..6e377ed 100755 --- a/build.sh +++ b/build.sh @@ -18,8 +18,9 @@ EOF apt-mirror -mkdir /workdir -cd /workdir +APPSTREAM_DIR=/workdir +mkdir ${APPSTREAM_DIR} +pushd ${APPSTREAM_DIR} cat < asgen-config.json { @@ -40,16 +41,18 @@ EOF appstream-generator process ${DIST} +popd + # Clear out the old data -rm -rf /repo/pantheon-data/main/* -rm -f /repo/debian/appstream-data-pantheon-icons-hidpi.install -rm -f /repo/debian/appstream-data-pantheon-icons.install -touch /repo/debian/appstream-data-pantheon-icons-hidpi.install -touch /repo/debian/appstream-data-pantheon-icons.install +rm -rf pantheon-data/main/* +rm -f debian/appstream-data-pantheon-icons-hidpi.install +rm -f debian/appstream-data-pantheon-icons.install +touch debian/appstream-data-pantheon-icons-hidpi.install +touch debian/appstream-data-pantheon-icons.install # Copy in the new -cp export/data/${DIST}/main/Components-amd64.yml.gz /repo/pantheon-data/main/pantheon_${DIST}-main_amd64.yml.gz -for f in export/data/${DIST}/main/icons-*; do +cp ${APPSTREAM_DIR}/export/data/${DIST}/main/Components-amd64.yml.gz pantheon-data/main/pantheon_${DIST}-main_amd64.yml.gz +for f in ${APPSTREAM_DIR}/export/data/${DIST}/main/icons-*; do # Ignore icon archives with no icons FILECOUNT=$(tar -tzvvf ${f} | grep -c ^-) || true @@ -57,13 +60,17 @@ for f in export/data/${DIST}/main/icons-*; do # Strip a path like export/data/bionic/main/icons-128x128@2.tar.gz down to 128x128@2 OUTDIR=`basename ${f} .tar.gz | cut -d- -f2` - mkdir -p /repo/pantheon-data/main/icons/${OUTDIR} - tar -C /repo/pantheon-data/main/icons/${OUTDIR} -xf ${f} + mkdir -p pantheon-data/main/icons/${OUTDIR} + tar -C pantheon-data/main/icons/${OUTDIR} -xf ${f} # Add the extracted directory path to the debian install scripts (either HiDPI or not) if [[ $OUTDIR == *"@2" ]]; then - echo "pantheon-data/main/icons/${OUTDIR}/* usr/share/app-info/icons/elementary-${CHANNEL}-${DIST}-main/$OUTDIR/" >> /repo/debian/appstream-data-pantheon-icons-hidpi.install + echo "pantheon-data/main/icons/${OUTDIR}/* usr/share/app-info/icons/elementary-${CHANNEL}-${DIST}-main/$OUTDIR/" >> debian/appstream-data-pantheon-icons-hidpi.install else - echo "pantheon-data/main/icons/${OUTDIR}/* usr/share/app-info/icons/elementary-${CHANNEL}-${DIST}-main/$OUTDIR/" >> /repo/debian/appstream-data-pantheon-icons.install + echo "pantheon-data/main/icons/${OUTDIR}/* usr/share/app-info/icons/elementary-${CHANNEL}-${DIST}-main/$OUTDIR/" >> debian/appstream-data-pantheon-icons.install fi done + +# Change the ownership to the current user +chown -R $(id -u):$(id -g) pantheon-data +chown -R $(id -u):$(id -g) debian diff --git a/commit.sh b/commit.sh deleted file mode 100755 index 6bb6912..0000000 --- a/commit.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -set -e - -apt-get update -apt-get install -y git - -# if a custom token is provided, use it instead of the default github token. -if [ -n "$GIT_USER_TOKEN" ]; then - GITHUB_TOKEN="$GIT_USER_TOKEN" -fi - -if [ -z "${GITHUB_TOKEN}" ]; then - echo "\033[0;31mERROR: The GITHUB_TOKEN environment variable is not defined.\033[0m" && exit 1 -fi - -# default email and username to github actions user -if [ -z "$GIT_USER_EMAIL" ]; then - GIT_USER_EMAIL="action@github.com" -fi -if [ -z "$GIT_USER_NAME" ]; then - GIT_USER_NAME="GitHub Action" -fi - -cd /repo - -git fetch -echo "Setting up git credentials..." -git remote set-url origin https://x-access-token:"$GITHUB_TOKEN"@github.com/"$GITHUB_REPOSITORY".git -git config --global user.email "$GIT_USER_EMAIL" -git config --global user.name "$GIT_USER_NAME" -echo "Git credentials configured." - -echo "Pushing new metadata to repository" -git checkout master -git add . -git commit -m "Automatic update of metadata" -git push --set-upstream origin master -echo "Push complete"