Commit 909c7069ce
Unsigned
Layout: unified · split
.github/workflows/update-aur.yml +15 −24
| @@ -32,6 +32,11 @@ jobs: | |||
| 32 | echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT | 32 | echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT |
| 33 | echo "Extracted version: $VERSION" | 33 | echo "Extracted version: $VERSION" |
| 34 | 34 | ||
| 35 | - name: Install dependencies | ||
| 36 | run: | | ||
| 37 | sudo apt-get update | ||
| 38 | sudo apt-get install -y expect git sshpass | ||
| 39 | |||
| 35 | - name: Set up SSH for AUR | 40 | - name: Set up SSH for AUR |
| 36 | run: | | 41 | run: | |
| 37 | mkdir -p ~/.ssh | 42 | mkdir -p ~/.ssh |
| @@ -49,6 +54,10 @@ jobs: | |||
| 49 | 54 | ||
| 50 | # Start SSH agent and add key with passphrase | 55 | # Start SSH agent and add key with passphrase |
| 51 | eval $(ssh-agent -s) | 56 | eval $(ssh-agent -s) |
| 57 | echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV | ||
| 58 | echo "SSH_AGENT_PID=$SSH_AGENT_PID" >> $GITHUB_ENV | ||
| 59 | |||
| 60 | # Use expect to add the key with passphrase | ||
| 52 | expect -c " | 61 | expect -c " |
| 53 | spawn ssh-add ~/.ssh/aur_rsa | 62 | spawn ssh-add ~/.ssh/aur_rsa |
| 54 | expect \"Enter passphrase\" | 63 | expect \"Enter passphrase\" |
| @@ -56,20 +65,9 @@ jobs: | |||
| 56 | expect eof | 65 | expect eof |
| 57 | " | 66 | " |
| 58 | 67 | ||
| 59 | - name: Install dependencies | ||
| 60 | run: | | ||
| 61 | sudo apt-get update | ||
| 62 | sudo apt-get install -y expect git | ||
| 63 | |||
| 64 | - name: Clone AUR repository | 68 | - name: Clone AUR repository |
| 65 | run: | | 69 | run: | |
| 66 | eval $(ssh-agent -s) | 70 | # The SSH agent should still be running with the key loaded |
| 67 | expect -c " | ||
| 68 | spawn ssh-add ~/.ssh/aur_rsa | ||
| 69 | expect \"Enter passphrase\" | ||
| 70 | send \"sex\r\" | ||
| 71 | expect eof | ||
| 72 | " | ||
| 73 | git clone ssh://aur@aur.archlinux.org/curd.git aur-curd | 71 | git clone ssh://aur@aur.archlinux.org/curd.git aur-curd |
| 74 | 72 | ||
| 75 | - name: Update PKGBUILD | 73 | - name: Update PKGBUILD |
| @@ -103,15 +101,6 @@ jobs: | |||
| 103 | - name: Commit and push to AUR | 101 | - name: Commit and push to AUR |
| 104 | working-directory: aur-curd | 102 | working-directory: aur-curd |
| 105 | run: | | 103 | run: | |
| 106 | # Start SSH agent for the commit/push | ||
| 107 | eval $(ssh-agent -s) | ||
| 108 | expect -c " | ||
| 109 | spawn ssh-add ~/.ssh/aur_rsa | ||
| 110 | expect \"Enter passphrase\" | ||
| 111 | send \"sex\r\" | ||
| 112 | expect eof | ||
| 113 | " 2>/dev/null | ||
| 114 | |||
| 115 | # Check if there are changes to commit | 104 | # Check if there are changes to commit |
| 116 | if git diff --quiet && git diff --cached --quiet; then | 105 | if git diff --quiet && git diff --cached --quiet; then |
| 117 | echo "No changes to commit" | 106 | echo "No changes to commit" |
| @@ -122,12 +111,14 @@ jobs: | |||
| 122 | git add PKGBUILD .SRCINFO | 111 | git add PKGBUILD .SRCINFO |
| 123 | git commit -m "Update to version ${{ steps.version.outputs.version }}" | 112 | git commit -m "Update to version ${{ steps.version.outputs.version }}" |
| 124 | 113 | ||
| 125 | # Push changes | 114 | # Push changes (SSH agent should still have the key loaded) |
| 126 | git push origin master | 115 | git push origin master |
| 127 | 116 | ||
| 128 | - name: Cleanup | 117 | - name: Cleanup |
| 129 | if: always() | 118 | if: always() |
| 130 | run: | | 119 | run: | |
| 131 | # Clean up SSH keys | 120 | # Clean up SSH keys and kill SSH agent |
| 132 | rm -f ~/.ssh/aur_rsa | 121 | rm -f ~/.ssh/aur_rsa |
| 133 | ssh-agent -k 2>/dev/null || true | 122 | if [ -n "$SSH_AGENT_PID" ]; then |
| 123 | kill $SSH_AGENT_PID 2>/dev/null || true | ||
| 124 | fi | ||