Skip to content

Commit e10d7ba

Browse files
authored
Update drupal-update.yml
Only process the output if composer update was successful
1 parent b73145a commit e10d7ba

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

.github/workflows/drupal-update.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,21 @@ jobs:
147147
- name: Update composer dependencies
148148
id: composer-update
149149
run: |
150-
{
151-
echo "commit_body<<EOF"
152-
composer update --no-scripts 2>&1 | tee composer_output.txt | grep -Pzo 'Lock file operations.*(\n|.)*Writing lock file' | tail -n +2 | head -n -1 | sed -r 's/ +?- ([^ ]+) //g'
153-
COMPOSERSTATUS=${PIPESTATUS[0]}
154-
echo "EOF"
155-
if [ $COMPOSERSTATUS -ne 0 ]; then
156-
cat composer_output.txt
157-
rm composer_output.txt
158-
exit $COMPOSERSTATUS;
159-
fi
160-
rm composer_output.txt
161-
} >> $GITHUB_OUTPUT
150+
echo "Running composer update..."
151+
output=$(composer update --no-scripts 2>&1)
152+
composer_exit_code=$?
153+
154+
# If composer update fails, exit with a non-zero status
155+
if [ $composer_exit_code -ne 0 ]; then
156+
echo "Composer update failed"
157+
echo "$output"
158+
exit $composer_exit_code
159+
fi
160+
161+
# Process output if successful
162+
echo "commit_body<<EOF" >> $GITHUB_OUTPUT
163+
echo "$output" | grep -Pzo 'Lock file operations.*(\n|.)*Writing lock file' | tail -n +2 | head -n -1 | sed -r 's/ +?- ([^ ]+) //g' >> $GITHUB_OUTPUT
164+
echo "EOF" >> $GITHUB_OUTPUT
162165

163166
- name: "Run composer normalize"
164167
id: composer-normalize

0 commit comments

Comments
 (0)