-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9859bc
commit e0acf49
Showing
1 changed file
with
27 additions
and
21 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 |
---|---|---|
|
@@ -2,23 +2,35 @@ name: "Code Deployment on Acquia Environment" | |
on: | ||
push: | ||
branches: [ develop, main, ACMS-4329 ] | ||
|
||
concurrency: | ||
group: "ci-${{ github.ref }}" | ||
cancel-in-progress: true | ||
|
||
env: | ||
GIT_AUTHOR_NAME: "CD" | ||
GIT_COMMITTER_NAME: "CD" | ||
GIT_COMMITTER_EMAIL: "[email protected]" | ||
GIT_AUTHOR_EMAIL: "[email protected]" | ||
PHP_VERSION: 8.3 | ||
CORE_VERSION: ^11 | ||
|
||
jobs: | ||
acquia_code_deployment: | ||
if: ${{ github.event_name == 'push' }} | ||
name: "Code Deployment on Acquia Environment" | ||
env: | ||
GIT_AUTHOR_NAME: "Vishal Khode" | ||
GIT_COMMITTER_NAME: "Vishal Khode" | ||
GIT_COMMITTER_EMAIL: "[email protected]" | ||
GIT_AUTHOR_EMAIL: "[email protected]" | ||
name: "Code Deployment" | ||
runs-on: ubuntu-latest | ||
environment: acquia_code_deployment | ||
concurrency: production | ||
env: | ||
ACQUIA_CLOUD_ENVIRONMENT: "dev" | ||
ACQUIA_CLOUD_API_KEY: ${{ secrets.ACQUIA_CLOUD_API_KEY }} | ||
ACQUIA_CLOUD_API_SECRET: ${{ secrets.ACQUIA_CLOUD_API_SECRET }} | ||
ACQUIA_CLOUD_APPLICATION: ${{ secrets.ACQUIA_CLOUD_APPLICATION }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.3 | ||
php-version: ${{ env.PHP_VERSION }} | ||
- name: Configure SSH keys | ||
run: | | ||
mkdir -p ~/.ssh | ||
|
@@ -64,9 +76,7 @@ jobs: | |
ln -s default headless | ||
ln -s default community | ||
cd - | ||
git add . && git commit -m "Update drupal core and it's dependencies." | ||
env: | ||
CORE_VERSION: ^11 | ||
git add . && git commit -m "Update drupal core and it's dependencies." 2>/dev/null | ||
- name: Setup Acquia CLI | ||
run: | | ||
curl -OL https://github.com/acquia/cli/releases/latest/download/acli.phar | ||
|
@@ -75,26 +85,24 @@ jobs: | |
acli --version | ||
acli auth:login --key=${ACQUIA_CLOUD_API_KEY} --secret=${ACQUIA_CLOUD_API_SECRET} -n | ||
ACQUIA_APPLICATION_UUID=$(acli api:applications:find ${ACQUIA_CLOUD_APPLICATION} -n | jq -r '.uuid') | ||
acli link ${ACQUIA_APPLICATION_UUID} -n | ||
acli remote:aliases:download -n | ||
git add . && git commit -m "Added acli & drush alias configurations." | ||
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 }} | ||
git add . && git commit -m "Added acli & drush alias configurations." 2>/dev/null | ||
- name: Deploy & Switch Code | ||
shell: bash | ||
run: | | ||
BRANCH_TO_DEPLOY=acli-${GITHUB_REF_NAME} | ||
acli push:artifact ${ACQUIA_CLOUD_ENVIRONMENT} --destination-git-branch=${BRANCH_TO_DEPLOY} -n | ||
acli push:artifact ${ACQUIA_CLOUD_APPLICATION}.${ACQUIA_CLOUD_ENVIRONMENT} --destination-git-branch=${BRANCH_TO_DEPLOY} -n | ||
DEPLOYED_BRANCH=$(acli api:environments:find ${ACQUIA_CLOUD_ENVIRONMENT} -n | jq -r '.vcs.path') | ||
DEPLOYED_BRANCH=$(acli api:environments:find ${ACQUIA_CLOUD_APPLICATION}.${ACQUIA_CLOUD_ENVIRONMENT} -n | jq -r '.vcs.path') | ||
# If BRANCH_TO_DEPLOY is NOT the same as DEPLOYED_BRANCH. Then switch code. | ||
if [ "$BRANCH_TO_DEPLOY" != "$DEPLOYED_BRANCH" ]; then | ||
# Step 1: Run the code:switch command and capture its output. | ||
response=$(acli api:environments:code-switch ${ACQUIA_CLOUD_ENVIRONMENT} ${BRANCH_TO_DEPLOY} -n) | ||
response=$(acli api:environments:code-switch ${ACQUIA_CLOUD_APPLICATION}.${ACQUIA_CLOUD_ENVIRONMENT} ${BRANCH_TO_DEPLOY} -n) | ||
# Step 2: Extract the notification ID from the JSON response | ||
notification_id=$(echo "$response" | jq -r '.notification') | ||
|
@@ -138,5 +146,3 @@ jobs: | |
sleep 5 | ||
done | ||
fi | ||
env: | ||
ACQUIA_CLOUD_ENVIRONMENT: ${{ secrets.ACQUIA_CLOUD_ENVIRONMENT }} |