From 07f09353ad43d33a2f0312150b2e82c7a12b9f89 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Sat, 28 Oct 2023 12:08:38 -0400 Subject: [PATCH 1/3] Support installing a specific ddev version #13 --- README.md | 12 ++++++++++++ action.yml | 4 ++++ lib/main.js | 16 +++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f95323..a874d94 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,18 @@ default: `true` autostart: false ``` +#### version + +Install a specific ddev version. The version must be available in ddev's apt repository. + +default: `latest` + +```yaml + - uses: ddev/github-action-setup-ddev@v1 + with: + version: 1.22.4 +``` + ## Common recipes ### SSH keys diff --git a/action.yml b/action.yml index ec3ca67..605729f 100644 --- a/action.yml +++ b/action.yml @@ -17,3 +17,7 @@ inputs: description: 'Start ddev automatically' required: false default: true + version: + description: 'Install a specific ddev version, such as 1.22.4' + required: false + default: 'latest' diff --git a/lib/main.js b/lib/main.js index c5af7b9..ff58774 100644 --- a/lib/main.js +++ b/lib/main.js @@ -65,9 +65,23 @@ function run() { cmd = 'echo "deb https://apt.fury.io/drud/ * *" | sudo tee -a /etc/apt/sources.list.d/ddev.list'; console.log(cmd); yield execShellCommand(cmd); - cmd = 'sudo apt-get update && sudo apt-get install -y ddev && mkcert -install'; + + const version = core.getInput('version') || 'latest'; + let ddevPackage = 'ddev'; + if (version !== 'latest') { + ddevPackage += `=${version}`; + } + + cmd = `sudo apt-get update && sudo apt-get install -y ${ddevPackage} && mkcert -install`; console.log(cmd); yield execShellCommand(cmd); + + if (version !== 'latest') { + cmd = 'sudo apt-mark hold ddev'; + console.log(cmd); + yield execShellCommand(cmd); + } + cmd = 'ddev --version'; console.log(cmd); yield execShellCommand(cmd); From f2b8a9205d6ebf5d480aefdcdae08921e597cbb7 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Sat, 28 Oct 2023 12:18:24 -0400 Subject: [PATCH 2/3] Add tests for setting the ddev version --- .github/workflows/main.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c8627a2..e37f713 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,12 +8,21 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, ubuntu-22.04] + version: ['latest', '1.22.3'] steps: - uses: actions/checkout@v3 - uses: ./ with: ddevDir: tests/fixtures/ddevProj1 autostart: false + version: ${{ matrix.version }} + - name: ddev version + run: | + if [[ ${{ matrix.version }} == '1.22.3' ]]; then + test $(ddev --version) == 'ddev version v1.22.3' + else + test $(ddev --version) != 'ddev version v1.22.3' + fi - name: ddev stopped run: | cd tests/fixtures/ddevProj1 From c8b803a26d8ba824b6700b9e26f09885586e1cee Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Sat, 28 Oct 2023 14:50:36 -0400 Subject: [PATCH 3/3] Add missing quotes in test --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e37f713..f3256c1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,9 +19,9 @@ jobs: - name: ddev version run: | if [[ ${{ matrix.version }} == '1.22.3' ]]; then - test $(ddev --version) == 'ddev version v1.22.3' + test "$(ddev --version)" == 'ddev version v1.22.3' else - test $(ddev --version) != 'ddev version v1.22.3' + test "$(ddev --version)" != 'ddev version v1.22.3' fi - name: ddev stopped run: |