-
Notifications
You must be signed in to change notification settings - Fork 36
133 lines (129 loc) · 5.62 KB
/
deployment.workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: "Code Deployment on Acquia Env"
on:
push:
branches: [ code-deployment ]
jobs:
acquia_code_deployment:
#if: ${{ github.ref == 'refs/heads/develop' && github.event_name == 'push' }}
name: "Code Deployment on Acquia Environment"
env:
GIT_AUTHOR_NAME: "Vishal Khode"
GIT_COMMITTER_NAME: "Vishal Khode"
GIT_COMMITTER_EMAIL: "vishal.khode@acquia.com"
GIT_AUTHOR_EMAIL: "vishal.khode@acquia.com"
BUILD_DIR: "/tmp/project"
runs-on: ubuntu-latest
environment: acquia_code_deployment
concurrency: production
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: shivammathur/setup-php@v2
with:
php-version: 8.3
- name: Configure SSH keys
run: |
mkdir -p ~/.ssh
echo "${ACQUIA_CLOUD_SSH_PRIVATE_KEY}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
eval `ssh-agent -s`
ssh-add ~/.ssh/id_rsa
ssh-keyscan -H "orionacmsdev.ssh.prod.acquia-sites.com" >> ~/.ssh/known_hosts
# Loop through each line in the environment variable.
echo "${ACQUIA_CLOUD_KNOWN_HOSTS}" | while IFS= read -r KNOWN_HOST; do
if [[ -n "${KNOWN_HOST}" ]]; then
CLEANED_HOST=$(echo "${KNOWN_HOST}" | tr -d '\r' | xargs -n1)
ssh-keyscan "${CLEANED_HOST}" >> ~/.ssh/known_hosts 2>/dev/null || {
echo "Warning: Unable to scan host ${CLEANED_HOST}. Skipping."
}
fi
done
shell: bash
env:
ACQUIA_CLOUD_SSH_PRIVATE_KEY: ${{ secrets.ACQUIA_CLOUD_SSH_PRIVATE_KEY }}
ACQUIA_CLOUD_KNOWN_HOSTS: ${{ vars.ACQUIA_CLOUD_KNOWN_HOSTS }}
# - name: Setup Drupal Project
# run: |
# mkdir -p ${BUILD_DIR}
# # We've to use different version of drupal-recommended-project based on Drupal Core version.
# if [[ "${CORE_VERSION}" == ^11* ]]; then
# composer create-project acquia/drupal-recommended-project:^3 ${BUILD_DIR} --no-install
# elif [[ "${CORE_VERSION}" == ^10* ]]; then
# composer create-project acquia/drupal-recommended-project:^2 ${BUILD_DIR} --no-install
# else
# echo "CORE_VERSION: ${CORE_VERSION} not supported."
# exit 1;
# fi
#
# cd $BUILD_DIR
#
# # Merging "allow-plugins", "extra", and "repositories" sections from Acquia Starter Kits' composer.json
# # into acquia/drupal-recommended-project's composer.json. This ensures that all dependencies,
# # plugins, and repositories are already set up in acquia/drupal-recommended-project
# # before requiring additional recipes or modules, so that all required dependencies are available.
# jq -s '.[0] * {
# "config": {
# "allow-plugins": (.[0].config."allow-plugins" + .[1].config."allow-plugins")
# },
# "extra": (.[0].extra + .[1].extra),
# "require": (.[0].require + .[1].require),
# "repositories": (
# (.[0].repositories + .[1].repositories) |
# map(
# if .type == "path" and (.url | test("^[^/]")) then
# .url = (env.GITHUB_WORKSPACE + "/" + .url | gsub("\\./"; ""))
# else
# .
# end
# )
# )
# }' composer.json ${GITHUB_WORKSPACE}/composer.json > temp_composer.json
#
# jq '.extra."drupal-scaffold"."file-mapping" |= del(
# .["[web-root]/themes/contrib/cohesion-theme/templates/maintenance-page.html.twig"],
# .["[web-root]/sites/default/default.settings.php"]
# )' temp_composer.json > updated_composer.json
#
# # Replace the original composer.json with the merged file.
# mv updated_composer.json composer.json
#
# # Pinning the drupal core dependencies to specific Drupal Core version.
# composer require drupal/core:${CORE_VERSION} drupal/core-recommended:${CORE_VERSION} drupal/core-composer-scaffold:${CORE_VERSION} --no-update --no-install
# rm composer.lock
# cat composer.json
#
# # Install all dependencies.
# composer install
# env:
# CORE_VERSION: ^11
- name: Setup Drupal Project
run: |
rm composer.lock
composer require acquia/drupal-recommended-settings --no-install --no-update
composer require drupal/core:${CORE_VERSION} --no-install --no-update
composer install
#composer update "drupal/core-*" drush/drush "drupal/*" -W --with=drupal/core:${CORE_VERSION}
env:
CORE_VERSION: ^11
- name: Setup Acquia Cloud CLI
run: |
curl -OL https://github.com/acquia/cli/releases/latest/download/acli.phar
chmod +x acli.phar
mv acli.phar /usr/local/bin/acli
acli --version
acli auth:login --key=${ACQUIA_CLOUD_API_KEY} --secret=${ACQUIA_CLOUD_API_SECRET} -n
acli link ${ACQUIA_APPLICATION_UUID} -n
acli remote:aliases:download -n
git add . && git commit -m "Added acli & drush alias configurations."
#printenv
acli push:artifact orionacms.dev --destination-git-branch=acli-${GITHUB_REF_NAME} -n -vvv || true
cd /tmp/acli-push-artifact
ls -ltr
ls -ltr docroot || true
ls -ltr docroot/core || true
cat composer.json || true
env:
ACQUIA_CLOUD_API_KEY: ${{ secrets.ACQUIA_CLOUD_API_KEY }}
ACQUIA_CLOUD_API_SECRET: ${{ secrets.ACQUIA_CLOUD_API_SECRET }}
ACQUIA_APPLICATION_UUID: ${{ secrets.ACQUIA_APPLICATION_UUID }}