From fcab7cfb1c4e61e759fb051b04d86668e3f896a0 Mon Sep 17 00:00:00 2001 From: Yarden Asado Date: Fri, 5 Apr 2024 17:26:29 -0400 Subject: [PATCH] use GNU gettext envsubst --- .github/workflows/deploy.yml | 11 ++-- github.sh | 122 +++++++++++++++++------------------ 2 files changed, 67 insertions(+), 66 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fe4dc5ba6be52..54f5aafd7c6c5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -46,17 +46,18 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: install envsubst - run: | - curl -L https://github.com/a8m/envsubst/releases/download/v1.2.0/envsubst-`uname -s`-`uname -m` -o envsubst - chmod +x envsubst - sudo mv envsubst /usr/local/bin + #- name: install envsubst + # run: | + # curl -L https://github.com/a8m/envsubst/releases/download/v1.2.0/envsubst-`uname -s`-`uname -m` -o envsubst + # chmod +x envsubst + # sudo mv envsubst /usr/local/bin - name: install dependencies. run: | sudo apt-get update -y sudo apt-get install -y cloud-utils sudo apt install -y pssh + sudo get install -y gettext - name: Configure AWS Credentials if: ${{ inputs.environment == 'staging' }} diff --git a/github.sh b/github.sh index 1b5c9d413b8a4..942b6ac66af7b 100755 --- a/github.sh +++ b/github.sh @@ -55,64 +55,64 @@ echo "print script rotate_version.sh:" cat rotate_version.sh -## When deploying to production, run using the "rocketchat-deploy" role -if [[ $environment == production ]] ; then - assumed_role_json=$( - aws \ - --output json \ - sts assume-role \ - --role-arn arn:aws:iam::618678420696:role/switch-account-deploy-rocket-chat \ - --role-session-name rocketchat-deploy - ) - assumed_role_variables=$( - echo "${assumed_role_json}" | jq -r \ - ' - "export AWS_SESSION_TOKEN=" + .Credentials.SessionToken + "\n" + - "export AWS_ACCESS_KEY_ID=" + .Credentials.AccessKeyId + "\n" + - "export AWS_SECRET_ACCESS_KEY=" + .Credentials.SecretAccessKey + "\n" - ' - ) - eval "$assumed_role_variables" -fi - -## Get instance IPs one per line (multiline string) -rc_instance_ips=$( - aws ec2 describe-instances \ - --filters Name=instance-state-name,Values=running \ - Name=tag:aws:autoscaling:groupName,Values=rocketchat \ - --query "Reservations[*].Instances[*].NetworkInterfaces[0].PrivateIpAddress" \ - --output text -) - - -## Install RC tarball (and its dependencies) onto all RC nodes -hr -echo "Installing new build onto all RC nodes:" -parallel-ssh \ - -x "-o StrictHostKeyChecking=no" \ - --inline --timeout 600 --user deploy \ - --hosts <(echo "$rc_instance_ips") \ - --send-input < ./pre_install.sh -hr - -## Activate new version -echo "Activating new build on all RC nodes:" -parallel-ssh \ - -x "-o StrictHostKeyChecking=no" \ - --inline --timeout 600 --user deploy \ - --hosts <(echo "$rc_instance_ips") \ - --send-input < ./rotate_version.sh -hr - -## Update the version marker file -echo "Mark which RC build is now active..." -current_marker_file="rocket.chat-$environment.tgz" -aws sts get-caller-identity -aws s3 cp "s3://$s3_bucket/$rc_tarball" "s3://$s3_bucket/$current_marker_file" --acl public-read -hr - -## Flush CDN -echo "Flushing $environment CDN" -FASTLY_SERVICE=$(aws ssm get-parameter --name /rocketchat/fastly_service_id --with-decryption --query Parameter.Value --output text) -FASTLY_TOKEN=$(aws ssm get-parameter --name /rocketchat/fastly_api_key --with-decryption --query Parameter.Value --output text) -curl -X POST -H "Fastly-Key: $FASTLY_TOKEN" "https://api.fastly.com/service/$FASTLY_SERVICE/purge/$environment" +### When deploying to production, run using the "rocketchat-deploy" role +#if [[ $environment == production ]] ; then +# assumed_role_json=$( +# aws \ +# --output json \ +# sts assume-role \ +# --role-arn arn:aws:iam::618678420696:role/switch-account-deploy-rocket-chat \ +# --role-session-name rocketchat-deploy +# ) +# assumed_role_variables=$( +# echo "${assumed_role_json}" | jq -r \ +# ' +# "export AWS_SESSION_TOKEN=" + .Credentials.SessionToken + "\n" + +# "export AWS_ACCESS_KEY_ID=" + .Credentials.AccessKeyId + "\n" + +# "export AWS_SECRET_ACCESS_KEY=" + .Credentials.SecretAccessKey + "\n" +# ' +# ) +# eval "$assumed_role_variables" +#fi +# +### Get instance IPs one per line (multiline string) +#rc_instance_ips=$( +# aws ec2 describe-instances \ +# --filters Name=instance-state-name,Values=running \ +# Name=tag:aws:autoscaling:groupName,Values=rocketchat \ +# --query "Reservations[*].Instances[*].NetworkInterfaces[0].PrivateIpAddress" \ +# --output text +#) +# +# +### Install RC tarball (and its dependencies) onto all RC nodes +#hr +#echo "Installing new build onto all RC nodes:" +#parallel-ssh \ +# -x "-o StrictHostKeyChecking=no" \ +# --inline --timeout 600 --user deploy \ +# --hosts <(echo "$rc_instance_ips") \ +# --send-input < ./pre_install.sh +#hr +# +### Activate new version +#echo "Activating new build on all RC nodes:" +#parallel-ssh \ +# -x "-o StrictHostKeyChecking=no" \ +# --inline --timeout 600 --user deploy \ +# --hosts <(echo "$rc_instance_ips") \ +# --send-input < ./rotate_version.sh +#hr +# +### Update the version marker file +#echo "Mark which RC build is now active..." +#current_marker_file="rocket.chat-$environment.tgz" +#aws sts get-caller-identity +#aws s3 cp "s3://$s3_bucket/$rc_tarball" "s3://$s3_bucket/$current_marker_file" --acl public-read +#hr +# +### Flush CDN +#echo "Flushing $environment CDN" +#FASTLY_SERVICE=$(aws ssm get-parameter --name /rocketchat/fastly_service_id --with-decryption --query Parameter.Value --output text) +#FASTLY_TOKEN=$(aws ssm get-parameter --name /rocketchat/fastly_api_key --with-decryption --query Parameter.Value --output text) +#curl -X POST -H "Fastly-Key: $FASTLY_TOKEN" "https://api.fastly.com/service/$FASTLY_SERVICE/purge/$environment"