Skip to content

Commit fb4d5d4

Browse files
Merge pull request #3976 from RedisInsight/feature/RI-6213_Migrate_to_Github_actions
RI-6213 - Migrate production workflow from Circleci to GitHub actions
2 parents 402c2a5 + 3656441 commit fb4d5d4

19 files changed

+878
-90
lines changed

.github/actions/install-all-build-libs/action.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ runs:
3939
cache: ${{ runner.os != 'Windows' && 'yarn' || '' }}
4040
cache-dependency-path: ${{ runner.os != 'Windows' && '**/yarn.lock' || '' }}
4141

42-
# - run: echo "inputs.skip-electron-deps"
43-
# - run: echo "${{inputs.skip-electron-deps}}"
44-
# - run: echo "inputs.skip-backend-deps"
45-
# - run: echo "${{inputs.skip-backend-deps}}"
46-
4742
- name: Setup Python
4843
# if: ${{ contains(inputs.skip-electron-deps, '1') }}
4944
uses: actions/setup-python@v5

.github/actions/install-deps/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ runs:
2626
# SKIP_POSTINSTALL: ${{ inputs.skip-postinstall }}
2727
# run: yarn install
2828
run: |
29-
export npm_config_keytar_binary_host_mirror=${{ inputs.keytar-host-mirror }}
30-
export npm_config_node_sqlite3_binary_host_mirror=${{ inputs.sqlite3-host-mirror }}
29+
# todo: uncomment after build our binaries
30+
# export npm_config_keytar_binary_host_mirror=${{ inputs.keytar-host-mirror }}
31+
# export npm_config_node_sqlite3_binary_host_mirror=${{ inputs.sqlite3-host-mirror }}
3132
3233
yarn install
33-
echo $SKIP_POSTINSTALL

.github/build/release-docker.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
set -e
3+
4+
HELP="Args:
5+
-v - Semver (2.58.0)
6+
-d - Build image repository (Ex: -d redisinsight)
7+
-r - Target repository (Ex: -r redis/redisinsight)
8+
"
9+
10+
while getopts "v:d:r:h:" opt; do
11+
case $opt in
12+
v) VERSION="$OPTARG";;
13+
d) DEV_REPO="$OPTARG";;
14+
r) RELEASE_REPO="$OPTARG";;
15+
h) echo "$HELP"; exit 0;;
16+
?) echo "$HELP" >&2; exit 1 ;;
17+
esac
18+
done
19+
20+
V_ARR=( ${VERSION//./ } )
21+
TAGS[0]=$VERSION
22+
TAGS[1]="${V_ARR[0]}.${V_ARR[1]}"
23+
TAGS[2]="latest"
24+
25+
DEV_IMAGE_AMD64=$DEV_REPO:amd64
26+
DEV_IMAGE_ARM64=$DEV_REPO:arm64
27+
RELEASE_IMAGE_AMD64=$RELEASE_REPO:$VERSION-amd64
28+
RELEASE_IMAGE_ARM64=$RELEASE_REPO:$VERSION-arm64
29+
30+
echo "
31+
TAGS: [${TAGS[0]}, ${TAGS[1]}, ${TAGS[2]}]
32+
DEV_REPO: $DEV_REPO
33+
RELEASE_REPO: $RELEASE_REPO
34+
35+
DEV_IMAGE_AMD64: $DEV_IMAGE_AMD64
36+
DEV_IMAGE_ARM64: $DEV_IMAGE_ARM64
37+
38+
RELEASE_IMAGE_AMD64: $RELEASE_IMAGE_AMD64
39+
RELEASE_IMAGE_ARM64: $RELEASE_IMAGE_ARM64
40+
"
41+
42+
# Load images from tar archives
43+
docker rmi $DEV_IMAGE_AMD64 || true
44+
docker rmi $DEV_IMAGE_ARM64 || true
45+
docker load -i release/docker-linux-alpine.amd64.tar
46+
docker load -i release/docker-linux-alpine.arm64.tar
47+
48+
echo "Push AMD64 image"
49+
docker tag $DEV_IMAGE_AMD64 $RELEASE_IMAGE_AMD64
50+
docker push $RELEASE_IMAGE_AMD64
51+
52+
echo "Push ARM64 image"
53+
docker tag $DEV_IMAGE_ARM64 $RELEASE_IMAGE_ARM64
54+
docker push $RELEASE_IMAGE_ARM64
55+
56+
for TAG in "${TAGS[@]}"; do
57+
echo "Releasing: $RELEASE_REPO:$TAG"
58+
docker manifest rm $RELEASE_REPO:$TAG || true
59+
docker manifest create --amend "$RELEASE_REPO:$TAG" $RELEASE_IMAGE_AMD64 $RELEASE_IMAGE_ARM64
60+
docker manifest push "$RELEASE_REPO:$TAG"
61+
done
62+
63+
echo "Success"

.github/virustotal-report.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const fs = require('fs');
2+
3+
const fileName = process.env.FILE_NAME;
4+
const buildName = process.env.BUILD_NAME;
5+
const failed = process.env.FAILED === 'true';
6+
7+
const results = {
8+
message: {
9+
text: `*Virustotal checks* (Branch: *${process.env.GITHUB_REF_NAME}*)` +
10+
`\n<https://github.com/RedisInsight/RedisInsight/actions/runs/${process.env.GITHUB_RUN_ID}|View on Github Actions>`,
11+
attachments: [],
12+
},
13+
};
14+
15+
const result = {
16+
color: '#36a64f',
17+
title: `Finished at: ${new Date().toISOString()}`,
18+
text: `All builds were passed via virustotal checks`,
19+
fields: [],
20+
};
21+
22+
if (failed) {
23+
results.passed = false;
24+
result.color = '#cc0000';
25+
result.text = 'Build had failed virustotal checks';
26+
result.fields.push({
27+
title: 'Failed build',
28+
value: buildName,
29+
short: true,
30+
});
31+
}
32+
33+
results.message.attachments.push(result);
34+
35+
if (failed === true) {
36+
results.message.text = '<!here> ' + results.message.text;
37+
}
38+
39+
40+
fs.writeFileSync(fileName, JSON.stringify({
41+
channel: process.env.SLACK_VIRUSTOTAL_REPORT_CHANNEL,
42+
...results.message,
43+
}));

.github/workflows/aws.yml

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
name: AWS
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
AWS_BUCKET_NAME: ${{ secrets.AWS_BUCKET_NAME }}
8+
AWS_DISTRIBUTION_ID: ${{ secrets.AWS_DISTRIBUTION_ID }}
9+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
10+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
11+
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
12+
13+
jobs:
14+
release-private:
15+
name: Release s3 private
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Download All Artifacts
21+
uses: actions/download-artifact@v4
22+
with:
23+
path: ./release
24+
25+
- run: ls -R ./release
26+
27+
- name: Publish private
28+
run: |
29+
30+
# Define array of folders to exclude
31+
exclude=("web" "web-mini" "redisstack" "docker")
32+
33+
# Iterate through first-level directories in ./release
34+
for dir in ./release/*/; do
35+
dir_name=$(basename "$dir")
36+
37+
# Check if the directory is not in the exclude list
38+
if [[ ! " ${exclude[@]} " =~ " ${dir_name} " ]]; then
39+
# Move all files from the subdirectory to the release directory
40+
mv "$dir"* ./release/
41+
42+
# Remove the now-empty subdirectory
43+
rmdir "$dir"
44+
fi
45+
done
46+
47+
chmod +x .circleci/build/sum_sha256.sh
48+
.circleci/build/sum_sha256.sh
49+
applicationVersion=$(jq -r '.version' redisinsight/package.json)
50+
51+
aws s3 cp release/ s3://${AWS_BUCKET_NAME}/private/${applicationVersion} --recursive
52+
53+
release-public:
54+
name: Release s3 public
55+
runs-on: ubuntu-latest
56+
needs: 'release-private'
57+
environment: 'production-approve'
58+
steps:
59+
- uses: actions/checkout@v4
60+
61+
- name: Init variables
62+
run: |
63+
latestYmlFileName="latest.yml"
64+
downloadLatestFolderPath="public/latest"
65+
upgradeLatestFolderPath="public/upgrades"
66+
releasesFolderPath="public/releases"
67+
appName=$(jq -r '.productName' electron-builder.json)
68+
appVersion=$(jq -r '.version' redisinsight/package.json)
69+
70+
echo "downloadLatestFolderPath=${downloadLatestFolderPath}" >> $GITHUB_ENV
71+
echo "upgradeLatestFolderPath=${upgradeLatestFolderPath}" >> $GITHUB_ENV
72+
echo "releasesFolderPath=${releasesFolderPath}" >> $GITHUB_ENV
73+
echo "applicationName=${appName}" >> $GITHUB_ENV
74+
echo "applicationVersion=${appVersion}" >> $GITHUB_ENV
75+
echo "appFileName=Redis-Insight" >> $GITHUB_ENV
76+
77+
# download latest.yml file to get last public version
78+
aws s3 cp s3://${AWS_BUCKET_NAME}/${downloadLatestFolderPath}/${latestYmlFileName} .
79+
80+
versionLine=$(head -1 ${latestYmlFileName})
81+
versionLineArr=(${versionLine/:// })
82+
previousAppVersion=${versionLineArr[1]}
83+
84+
echo "previousApplicationVersion=${previousAppVersion}" >> $GITHUB_ENV
85+
86+
- name: Publish AWS S3
87+
run: |
88+
89+
# check if sub directories exists
90+
if [[ -z "$downloadLatestFolderPath" || -z "$upgradeLatestFolderPath" ]]; then
91+
exit 1;
92+
fi
93+
# remove previous build from the latest directory /public/latest
94+
aws s3 rm s3://${AWS_BUCKET_NAME}/${downloadLatestFolderPath} --recursive
95+
96+
# remove previous build from the upgrade directory /public/upgrades
97+
aws s3 rm s3://${AWS_BUCKET_NAME}/${upgradeLatestFolderPath} --recursive
98+
99+
# copy current version apps for download to /public/latest
100+
aws s3 cp s3://${AWS_BUCKET_NAME}/private/${applicationVersion}/ \
101+
s3://${AWS_BUCKET_NAME}/${downloadLatestFolderPath} --recursive --exclude "*.zip"
102+
103+
# copy current version apps for upgrades to /public/upgrades
104+
aws s3 cp s3://${AWS_BUCKET_NAME}/private/${applicationVersion}/ \
105+
s3://${AWS_BUCKET_NAME}/${upgradeLatestFolderPath} --recursive
106+
107+
# !MOVE current version apps to releases folder /public/releases
108+
aws s3 mv s3://${AWS_BUCKET_NAME}/private/${applicationVersion}/ \
109+
s3://${AWS_BUCKET_NAME}/${releasesFolderPath}/${applicationVersion} --recursive
110+
111+
# invalidate cloudfront cash
112+
aws cloudfront create-invalidation --distribution-id ${AWS_DISTRIBUTION_ID} --paths "/*"
113+
114+
- name: Add tags for all objects and create S3 metrics
115+
run: |
116+
117+
# declare all tags
118+
declare -A tag0=(
119+
[arch]='x64'
120+
[platform]='macos'
121+
[objectDownload]=${appFileName}'-mac-x64.dmg'
122+
[objectUpgrade]=${appFileName}'-mac-x64.zip'
123+
)
124+
125+
declare -A tag1=(
126+
[arch]='arm64'
127+
[platform]='macos'
128+
[objectDownload]=${appFileName}'-mac-arm64.dmg'
129+
[objectUpgrade]=${appFileName}'-mac-arm64.zip'
130+
)
131+
132+
declare -A tag2=(
133+
[arch]='x64'
134+
[platform]='windows'
135+
[objectDownload]=${appFileName}'-win-installer.exe'
136+
)
137+
138+
declare -A tag3=(
139+
[arch]='x64'
140+
[platform]='linux_AppImage'
141+
[objectDownload]=${appFileName}'-linux-x86_64.AppImage'
142+
)
143+
144+
declare -A tag4=(
145+
[arch]='x64'
146+
[platform]='linux_deb'
147+
[objectDownload]=${appFileName}'-linux-amd64.deb'
148+
)
149+
150+
declare -A tag5=(
151+
[arch]='x64'
152+
[platform]='linux_rpm'
153+
[objectDownload]=${appFileName}'-linux-x86_64.rpm'
154+
)
155+
156+
# loop for add all tags to each app and create metrics
157+
declare -n tag
158+
for tag in ${!tag@}; do
159+
160+
designation0="downloads"
161+
designation1="upgrades"
162+
163+
id0="${tag[platform]}_${tag[arch]}_${designation0}_${applicationVersion}"
164+
id1="${tag[platform]}_${tag[arch]}_${designation1}_${applicationVersion}"
165+
166+
# add tags to each app for download
167+
aws s3api put-object-tagging \
168+
--bucket ${AWS_BUCKET_NAME} \
169+
--key ${downloadLatestFolderPath}/${tag[objectDownload]} \
170+
--tagging '{"TagSet": [{ "Key": "version", "Value": "'"${applicationVersion}"'" }, {"Key": "platform", "Value": "'"${tag[platform]}"'"}, {"Key": "arch", "Value": "'"${tag[arch]}"'"}, { "Key": "designation", "Value": "'"${designation0}"'" }]}'
171+
172+
# add tags to each app for upgrades
173+
aws s3api put-object-tagging \
174+
--bucket ${AWS_BUCKET_NAME} \
175+
--key ${upgradeLatestFolderPath}/${tag[objectUpgrade]:=${tag[objectDownload]}} \
176+
--tagging '{"TagSet": [{ "Key": "version", "Value": "'"${applicationVersion}"'" }, {"Key": "platform", "Value": "'"${tag[platform]}"'"}, {"Key": "arch", "Value": "'"${tag[arch]}"'"}, { "Key": "designation", "Value": "'"${designation1}"'" }]}'
177+
178+
# Create metrics for all tags for downloads to S3
179+
aws s3api put-bucket-metrics-configuration \
180+
--bucket ${AWS_BUCKET_NAME} \
181+
--id ${id0} \
182+
--metrics-configuration '{"Id": "'"${id0}"'", "Filter": {"And": {"Tags": [{"Key": "platform", "Value": "'"${tag[platform]}"'"}, {"Key": "arch", "Value": "'"${tag[arch]}"'"}, {"Key": "designation", "Value": "'"${designation0}"'"}, {"Key": "version", "Value": "'"${applicationVersion}"'"} ]}}}'
183+
184+
# Create metrics for all tags for upgrades to S3
185+
aws s3api put-bucket-metrics-configuration \
186+
--bucket ${AWS_BUCKET_NAME} \
187+
--id ${id1} \
188+
--metrics-configuration '{"Id": "'"${id1}"'", "Filter": {"And": {"Tags": [{"Key": "platform", "Value": "'"${tag[platform]}"'"}, {"Key": "arch", "Value": "'"${tag[arch]}"'"}, {"Key": "designation", "Value": "'"${designation1}"'"}, {"Key": "version", "Value": "'"${applicationVersion}"'"}]}}}'
189+
190+
done

0 commit comments

Comments
 (0)