Skip to content

Commit d39c389

Browse files
Enhance GitHub Actions workflow for package updates:
- Modify Docker run command to include privileged mode for better access. - Streamline package update process by consolidating commands within the container. - Improve clarity and organization of update checks and output handling. - Ensure cleanup of temporary files is handled correctly after job completion.
1 parent 3443791 commit d39c389

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

.github/workflows/update-packages.yaml

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
4040
- name: Set up Docker
4141
run: |
42-
docker run --name arch-container -d \
42+
docker run --privileged --name arch-container -d \
4343
-v ${{ env.WORKSPACE }}:/workdir \
4444
-v /tmp/pacman-cache:/var/cache/pacman/pkg \
4545
archlinux:latest sleep infinity
@@ -48,24 +48,28 @@ jobs:
4848
run: |
4949
docker exec arch-container bash -c "
5050
set -euo pipefail
51+
cd /workdir
52+
53+
# Update package database
5154
pacman -Sy --noconfirm
55+
56+
# Install required packages
5257
pacman -S --noconfirm --needed curl jq
5358
"
5459
5560
- name: Check for Package Updates
5661
id: check-updates
5762
run: |
58-
# Create temporary files in workspace
59-
touch current-packages.txt updates.txt
60-
61-
# Get current packages
62-
grep -v '^#' packages.x86_64 | grep -v '^$' > current-packages.txt
63-
64-
# Check each package for updates
6563
docker exec arch-container bash -c "
6664
set -euo pipefail
6765
cd /workdir
6866
67+
# Create temporary files in workspace
68+
touch current-packages.txt updates.txt
69+
70+
# Get current packages
71+
grep -v '^#' packages.x86_64 | grep -v '^$' > current-packages.txt
72+
6973
# Initialize pacman
7074
pacman -Sy
7175
@@ -78,17 +82,17 @@ jobs:
7882
echo \"Warning: Package \$pkg not found in repositories\"
7983
fi
8084
done < current-packages.txt
85+
86+
# Check if we have updates
87+
if [ -s updates.txt ]; then
88+
echo 'updates_available=true' >> \$GITHUB_OUTPUT
89+
echo 'Found updates:'
90+
cat updates.txt
91+
else
92+
echo 'updates_available=false' >> \$GITHUB_OUTPUT
93+
echo 'No updates found'
94+
fi
8195
"
82-
83-
# Check if we have updates
84-
if [ -s updates.txt ]; then
85-
echo "updates_available=true" >> $GITHUB_OUTPUT
86-
echo "Found updates:"
87-
cat updates.txt
88-
else
89-
echo "updates_available=false" >> $GITHUB_OUTPUT
90-
echo "No updates found"
91-
fi
9296
9397
- name: Create Pull Request
9498
if: steps.check-updates.outputs.updates_available == 'true'
@@ -118,5 +122,4 @@ jobs:
118122
run: |
119123
docker stop arch-container || true
120124
docker rm arch-container || true
121-
rm -f current-packages.txt updates.txt
122125
sudo rm -rf /tmp/pacman-cache/*

0 commit comments

Comments
 (0)