-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use new composer lock diff workflow.
- Loading branch information
Showing
10 changed files
with
246 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
name: 'Install and Start DDEV' | ||
description: 'Installs the latest or specified version of DDEV and starts the project' | ||
inputs: | ||
ssh-private-key: | ||
description: "SSH Private Key" | ||
required: false | ||
ssh-known-hosts: | ||
description: "SSH Known Hosts" | ||
required: false | ||
git-email: | ||
description: "Git e-mail address" | ||
required: false | ||
git-name: | ||
description: "Git name" | ||
required: false | ||
composer-cache-dir: | ||
description: "Composer cache directory, relative to the project workspace. Set to false to disable." | ||
required: false | ||
version: | ||
description: "Override the DDEV version .e.g. '1.19.0'" | ||
required: false | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install and Start DDEV | ||
run: | | ||
curl https://apt.fury.io/drud/gpg.key | sudo apt-key add - | ||
echo "deb https://apt.fury.io/drud/ * *" | sudo tee -a /etc/apt/sources.list.d/ddev.list | ||
sudo apt update | ||
sudo apt install libnss3-tools -y | ||
mkdir -p .ddev/homeadditions/.ssh | ||
# Copy private key | ||
if [ "${{ inputs.ssh-private-key }}" != "" ]; then | ||
echo "${{ inputs.ssh-private-key }}" > .ddev/homeadditions/.ssh/id_rsa | ||
chmod 600 .ddev/homeadditions/.ssh/id_rsa | ||
fi | ||
# Copy known hosts | ||
if [ "${{ inputs.ssh-known-hosts }}" != "" ]; then | ||
echo "${{ inputs.ssh-known-hosts}}" > .ddev/homeadditions/.ssh/known_hosts | ||
chmod 644 .ddev/homeadditions/.ssh/known_hosts | ||
fi | ||
# SSH config file | ||
touch .ddev/homeadditions/.ssh/config | ||
# Disable strict host key checking for Pantheon as ssh-keyscan will not | ||
# return a stable response. | ||
if [ -f "pantheon.yml" ]; then | ||
echo -e "Host *.drush.in\\n\\tStrictHostKeyChecking no\\n\tLogLevel ERROR\\n" >> .ddev/homeadditions/.ssh/config | ||
fi | ||
chmod 600 .ddev/homeadditions/.ssh/config | ||
chmod 700 .ddev/homeadditions/.ssh | ||
# Download and run the DDEV installer | ||
if [ "${{ inputs.version }}" != "" ]; then | ||
sudo apt install -y ddev=${{inputs.version}} | ||
else | ||
sudo apt install -y ddev | ||
fi | ||
# Support local runner https://github.com/nektos/act | ||
if [ "$ACT" != "" ]; then | ||
sudo chown runner:docker /var/run/docker.sock | ||
fi | ||
ddev config global --instrumentation-opt-in=false --omit-containers=ddev-ssh-agent | ||
if [ "${{ inputs.composer-cache-dir }}" != "false" ]; then | ||
# @todo Replace /var/www/html with an environment variable. | ||
CACHE_DIR=".ddev/.drainpipe-composer-cache" | ||
if [ "${{ inputs.composer-cache-dir }}" != "" ]; then | ||
CACHE_DIR="${{ inputs.composer-cache-dir }}" | ||
fi | ||
# Workaround for https://github.com/ddev/ddev/issues/6044 | ||
if yq -re .type .ddev/config.yaml; then | ||
ddev config --web-environment-add="COMPOSER_CACHE_DIR=/var/www/html/$CACHE_DIR" --project-type="$(yq -re .type .ddev/config.yaml)" | ||
else | ||
ddev config --web-environment-add="COMPOSER_CACHE_DIR=/var/www/html/$CACHE_DIR" | ||
fi | ||
fi | ||
ddev start | ||
ddev describe | ||
# Copy git credentials | ||
ddev exec "git config --global user.name \"${{ inputs.git-name }}\"" | ||
ddev exec "git config --global user.email \"${{ inputs.git-email }}\"" | ||
echo "DRAINPIPE_DDEV=true" >> $GITHUB_ENV | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: 'Set Env' | ||
description: 'Creates some useful environment variables' | ||
inputs: | ||
github-api-token: | ||
description: "GitHub API token" | ||
required: true | ||
github-api-token-username: | ||
description: "GitHub API token username" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- run: | | ||
echo "Setting Drainpipe environment variables:" | ||
echo "DRAINPIPE_PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')" >> $GITHUB_ENV | ||
echo "DRAINPIPE_SHA=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha)" >> $GITHUB_ENV | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
drainpipe_exec() { | ||
if [ "$DRAINPIPE_DDEV" == "true" ]; then | ||
ddev exec "$@" | ||
else | ||
eval "$@" | ||
fi | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: 'Configure git' | ||
description: 'Configures git username and e-mail address' | ||
inputs: | ||
git-email: | ||
description: "Git e-mail address" | ||
required: true | ||
git-name: | ||
description: "Git name" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- run: | | ||
git config --global user.email ${{ inputs.git-email }} | ||
git config --global user.name ${{ inputs.git-name }} | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: 'Configure ssh' | ||
description: 'Configures SSH' | ||
inputs: | ||
ssh-private-key: | ||
description: "SSH Private Key" | ||
required: true | ||
ssh-known-hosts: | ||
description: "SSH Known Hosts" | ||
required: false | ||
runs: | ||
using: "composite" | ||
steps: | ||
- run: | | ||
sudo apt-get update | ||
sudo apt-get install -y openssh-client | ||
eval $(ssh-agent -s) | ||
echo "${{ inputs.ssh-private-key }}" | tr -d '\r' | ssh-add - | ||
mkdir -p ~/.ssh | ||
chmod 700 ~/.ssh | ||
touch ~/.ssh/config | ||
chmod 600 ~/.ssh/config | ||
if [ "${{ inputs.ssh-known-hosts}}" != "" ]; then | ||
echo "${{ inputs.ssh-known-hosts }}" >> ~/.ssh/known_hosts | ||
chmod 644 ~/.ssh/known_hosts | ||
fi | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: "Composer Lock Diff" | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
Composer-Lock-Diff: | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Check if composer.lock was changed | ||
id: composer-lock-changed | ||
uses: tj-actions/changed-files@v44 | ||
with: | ||
files: 'composer.lock' | ||
|
||
- name: Delete sticky pull request comment | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: composer-lock-diff | ||
delete: true | ||
|
||
- uses: actions/cache@v4 | ||
if: ${{ steps.composer-lock-changed.outputs.any_changed == 'true' }} | ||
with: | ||
path: ${{ github.workspace }}/.ddev/.drainpipe-composer-cache | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: Generate composer diff | ||
if: ${{ steps.composer-lock-changed.outputs.any_changed == 'true' }} | ||
id: composer-diff | ||
uses: IonBazan/composer-diff-action@v1 | ||
with: | ||
base: ${{ github.base_ref || github.ref_name }} | ||
with-platform: true | ||
with-links: true | ||
|
||
- name: Post sticky pull request comment | ||
if: ${{ steps.composer-lock-changed.outputs.any_changed == 'true' }} | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: composer-lock-diff | ||
message: | | ||
### Composer package changes | ||
${{ (steps.composer-diff.outcome != 'success' && 'Review any changes to composer.lock manually.') || steps.composer-diff.outputs.composer_diff || 'No changes found' }} |
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.