Merge pull request #9 from irfanhakim-as/rename #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update AUR | |
on: | |
push: | |
branches: | |
- master # monitor changes only in the master branch | |
paths: | |
- PKGBUILD # monitor changes to the PKGBUILD file | |
workflow_dispatch: # allow manually triggering the workflow | |
env: | |
REMOTE_HOST: aur.archlinux.org | |
REMOTE_HOST_USER: aur | |
REMOTE_HOST_PREFIX: ssh | |
REMOTE_REPO_NAMESPACE: '' | |
REMOTE_REPO_NAME: kf6-servicemenus-reimage | |
REMOTE_REPO_USER: irfanhakim | |
REMOTE_REPO_EMAIL: [email protected] | |
jobs: | |
update-aur: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
id: checkout | |
uses: actions/checkout@v3 | |
- name: Set up SSH | |
id: configure_ssh | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.AUR_PRIVATE_KEY }} | |
- name: Add remote host to known hosts | |
id: add_remote_host | |
run: | | |
ssh-keyscan ${REMOTE_HOST} >> ~/.ssh/known_hosts | |
- name: Clone the remote repository | |
id: clone_remote_repo | |
run: | | |
# set variables | |
REMOTE_HOST_PREFIX="${{ env.REMOTE_HOST_PREFIX }}${{ env.REMOTE_HOST_PREFIX && '://' }}" | |
REMOTE_REPO_NAMESPACE="${{ env.REMOTE_REPO_NAMESPACE && ':' }}${{ env.REMOTE_REPO_NAMESPACE }}" | |
# clone remote repository | |
git clone ${REMOTE_HOST_PREFIX}${REMOTE_HOST_USER:-git}@${REMOTE_HOST}${REMOTE_REPO_NAMESPACE}/${REMOTE_REPO_NAME}.git | |
- name: Copy package files to remote repository | |
id: copy_pkgfiles | |
run: | | |
cp .SRCINFO PKGBUILD ${REMOTE_REPO_NAME}/ | |
- name: Check if package files have changes | |
id: check_changes | |
run: | | |
# change working directory | |
cd ${REMOTE_REPO_NAME} | |
# add package files | |
git add .SRCINFO PKGBUILD | |
# check for changes | |
if git diff --cached --exit-code >/dev/null; then | |
echo "No changes have been made to the package files." | |
exists=false | |
else | |
echo "Package files have been updated and are pending commit." | |
exists=true | |
fi | |
# export result to output | |
echo "exists=${exists}" | tee -a ${GITHUB_OUTPUT} | |
- name: Commit and push updated package files | |
id: push_changes | |
if: steps.check_changes.outputs.exists == 'true' | |
run: | | |
# set variables | |
source PKGBUILD | |
version="${pkgver}" | |
release="${pkgrel}" | |
# change working directory | |
cd ${REMOTE_REPO_NAME} | |
# configure git | |
git config --local user.name "${REMOTE_REPO_USER:-github-actions[bot]}" | |
git config --local user.email "${REMOTE_REPO_EMAIL:-github-actions[bot]@users.noreply.github.com}" | |
# commit changes | |
git commit -m "Update to ${version}-${pkgrel}" | |
# push commit | |
git push -u origin HEAD |