-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release: copy cloudflare assets when promoting (#3505)
- Loading branch information
Showing
6 changed files
with
98 additions
and
0 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 |
---|---|---|
|
@@ -32,3 +32,6 @@ | |
|
||
- include: tasks/metrics.yaml | ||
tags: metrics | ||
|
||
- include: tasks/cloudflare.yaml | ||
tags: cloudflare |
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,45 @@ | ||
--- | ||
|
||
- name: create .aws directory | ||
ansible.builtin.file: | ||
dest: "dist/.aws" | ||
owner: dist | ||
group: dist | ||
state: directory | ||
|
||
- name: copy credentials to deploy release artifacts | ||
ansible.builtin.copy: | ||
content: "{{ secrets.worker_credentials }}" | ||
dest: "dist/.aws/credentials" | ||
owner: dist | ||
group: dist | ||
|
||
- name: write worker_config | ||
ansible.builtin.copy: | ||
dest: "dist/.aws/config" | ||
src: "{{ role_path }}/files/worker_config" | ||
owner: dist | ||
group: dist | ||
|
||
|
||
# https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html | ||
- name: Download awscliv2 installer | ||
unarchive: | ||
src: "https://awscli.amazonaws.com/awscli-exe-linux-{{ ansible_architecture }}.zip" | ||
dest: "/tmp" | ||
remote_src: true | ||
creates: '/tmp/aws' | ||
mode: 0755 | ||
|
||
- name: Run awscliv2 installer | ||
command: | ||
args: | ||
cmd: "/tmp/aws/install" | ||
creates: /usr/local/bin/aws | ||
become: true | ||
register: aws_install | ||
|
||
- name: "Show awscliv2 installer output" | ||
debug: | ||
var: aws_install | ||
verbosity: 2 |
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
43 changes: 43 additions & 0 deletions
43
ansible/www-standalone/tools/promote/upload_to_cloudflare.sh
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,43 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
site=$1 | ||
|
||
if [ "X$site" != "Xiojs" ] && [ "X$site" != "Xnodejs" ]; then | ||
echo "Usage: upload_to_cloudflare.sh < iojs | nodejs > <version>" | ||
exit 1 | ||
fi | ||
|
||
if [ "X$2" == "X" ]; then | ||
echo "Usage: upload_to_cloudflare.sh < iojs | nodejs > <version>" | ||
exit 1 | ||
fi | ||
|
||
if [ -z ${dstdir+x} ]; then | ||
echo "\$dstdir is not set" | ||
exit 1 | ||
fi | ||
if [ -z ${dist_rootdir+x} ]; then | ||
echo "\$dist_rootdir is not set" | ||
exit 1 | ||
fi | ||
if [ -z ${destination_bucket+x} ]; then | ||
echo "\$destination_bucket is not set" | ||
exit 1 | ||
fi | ||
if [ -z ${cloudflare_endpoint+x} ]; then | ||
echo "\$cloudflare_endpoint is not set" | ||
exit 1 | ||
fi | ||
if [ -z ${cloudflare_profile+x} ]; then | ||
echo "\$cloudflare_profile is not set" | ||
exit 1 | ||
fi | ||
|
||
relativedir=${dstdir/$dist_rootdir/"$site/"} | ||
tmpversion=$2 | ||
|
||
aws s3 cp $dstdir/$tmpversion/ $destination_bucket/$relativedir/$tmpversion/ --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile --recursive | ||
aws s3 cp $dstdir/index.json $destination_bucket/$relativedir/index.json --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile | ||
aws s3 cp $dstdir/index.tab $destination_bucket/$relativedir/index.tab --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile |