1+ # .github/workflows/dependency-updates.yml
2+ # Automate dependency updates.
3+ # Runs composer update, database updates, exports configurations, generates a
4+ # composer.lock diff, and creates a pull request.
5+ name : Automated Dependency Updates
6+
7+ on :
8+ schedule :
9+ - cron : ' 0 14 * * 5'
10+ workflow_dispatch :
11+
12+ jobs :
13+ update-dependencies :
14+ name : Update Composer Dependencies
15+ runs-on : ubuntu-latest
16+ container :
17+ image : pookmish/drupal8ci:php8.3
18+ options : ' --network-alias drupal8ci'
19+ env :
20+ DRUPAL_DATABASE_NAME : drupal
21+ DRUPAL_DATABASE_USERNAME : drupal
22+ DRUPAL_DATABASE_PASSWORD : drupal
23+ DRUPAL_DATABASE_HOST : mysql
24+ services :
25+ mysql :
26+ image : mysql:5.7
27+ env :
28+ MYSQL_DATABASE : drupal
29+ MYSQL_USER : drupal
30+ MYSQL_PASSWORD : drupal
31+ MYSQL_ROOT_PASSWORD : drupal
32+ ports :
33+ - 33306:3306
34+ options : --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
35+ steps :
36+ - name : Checkout repository
37+ uses : actions/checkout@v4
38+ with :
39+ fetch-depth : 0
40+ - name : Set git safe directory
41+ run : git config --system --add safe.directory '*'
42+ - name : Set date variable
43+ id : date
44+ run : echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
45+ - name : Restore Cache
46+ uses : actions/cache@v4
47+ with :
48+ path : |
49+ vendor
50+ docroot/core
51+ docroot/libraries
52+ docroot/modules/contrib
53+ key : 4.0-${{ hashFiles('blt/blt.yml') }}-${{ hashFiles('composer.json') }}-${{ hashFiles('composer.lock') }}
54+ - name : Install dependencies
55+ run : composer install -n
56+ - name : Install Drupal site
57+ run : |
58+ mysql -h mysql -P 3306 -u root -pdrupal -e 'SET GLOBAL max_allowed_packet=67108864;'
59+ rm -rf /var/www/html
60+ ln -snf $GITHUB_WORKSPACE /var/www/html
61+ mkdir -p docroot/sites/default/files
62+ chmod -R 777 docroot/sites/default/files/
63+ blt drupal:install -n
64+ - name : Import configuration
65+ run : drush cim -y
66+ - name : Update Composer dependencies
67+ run : composer update -W -n
68+ - name : Update database
69+ run : drush updatedb -y
70+ - name : Export configuration
71+ run : drush config:export -y
72+ - name : Generate composer.lock diff (markdown)
73+ id : lockdiff
74+ run : |
75+ vendor/bin/composer-lock-diff --md --from origin/${{ github.event.repository.default_branch }}:composer.lock --to composer.lock > composer-lock-diff.md
76+ echo "diff<<EOF" >> $GITHUB_OUTPUT
77+ cat composer-lock-diff.md >> $GITHUB_OUTPUT
78+ echo "EOF" >> $GITHUB_OUTPUT
79+ rm composer-lock-diff.md
80+ - name : Get outdated direct dependencies
81+ id : outdated
82+ run : |
83+ echo 'outdated<<EOF' >> $GITHUB_OUTPUT
84+ echo '```' >> $GITHUB_OUTPUT
85+ composer outdated --direct >> $GITHUB_OUTPUT
86+ echo '```' >> $GITHUB_OUTPUT
87+ echo 'EOF' >> $GITHUB_OUTPUT
88+ - name : Create Pull Request
89+ uses : peter-evans/create-pull-request@v7
90+ with :
91+ token : ${{ secrets.GITHUB_TOKEN }}
92+ commit-message : " Automated Dependency Updates ${{ steps.date.outputs.date }}"
93+ branch : automated/dependency-update-${{ steps.date.outputs.date }}-${{ github.run_id }}
94+ base : ${{ github.event.repository.default_branch }}
95+ title : " Automated Dependency Updates ${{ steps.date.outputs.date }}"
96+ body : |
97+ This PR was created automatically by a scheduled GitHub Actions workflow to update Composer dependencies and export Drupal configuration.
98+
99+ ## Composer Dependency Changes
100+ ${{ steps.lockdiff.outputs.diff }}
101+
102+ ## Outdated Direct Composer Dependencies
103+ ${{ steps.outdated.outputs.outdated }}
104+ assignees : ${{ secrets.PR_ASSIGNEE || 'joegl' }}
0 commit comments