-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update ECS deployment script to disable strict host key checking
- Loading branch information
Showing
1 changed file
with
80 additions
and
79 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 |
---|---|---|
|
@@ -5,85 +5,85 @@ on: | |
branches: | ||
- master | ||
jobs: | ||
build: | ||
environment: production | ||
concurrency: | ||
group: build-${{ github.ref }} | ||
cancel-in-progress: true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
# build: | ||
# environment: production | ||
# concurrency: | ||
# group: build-${{ github.ref }} | ||
# cancel-in-progress: true | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v3 | ||
|
||
- uses: benjlevesque/[email protected] | ||
id: short-sha | ||
with: | ||
length: 7 | ||
# - uses: benjlevesque/[email protected] | ||
# id: short-sha | ||
# with: | ||
# length: 7 | ||
|
||
- name: Login to Docker | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: registry.ap-southeast-1.aliyuncs.com | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
# - name: Login to Docker | ||
# uses: docker/login-action@v2 | ||
# with: | ||
# registry: registry.ap-southeast-1.aliyuncs.com | ||
# username: ${{ secrets.DOCKER_USERNAME }} | ||
# password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Login to Docker | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: registry.cn-shenzhen.aliyuncs.com | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
# - name: Login to Docker | ||
# uses: docker/login-action@v2 | ||
# with: | ||
# registry: registry.cn-shenzhen.aliyuncs.com | ||
# username: ${{ secrets.DOCKER_USERNAME }} | ||
# password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build docker image and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
push: true | ||
context: . | ||
tags: | | ||
registry.ap-southeast-1.aliyuncs.com/kemono/image-optimizer:master-${{ env.SHA }} | ||
registry.ap-southeast-1.aliyuncs.com/kemono/image-optimizer:latest | ||
registry.cn-shenzhen.aliyuncs.com/kemono/image-optimizer:master-${{ env.SHA }} | ||
registry.cn-shenzhen.aliyuncs.com/kemono/image-optimizer:latest | ||
file: Dockerfile | ||
# - name: Build docker image and push | ||
# uses: docker/build-push-action@v3 | ||
# with: | ||
# push: true | ||
# context: . | ||
# tags: | | ||
# registry.ap-southeast-1.aliyuncs.com/kemono/image-optimizer:master-${{ env.SHA }} | ||
# registry.ap-southeast-1.aliyuncs.com/kemono/image-optimizer:latest | ||
# registry.cn-shenzhen.aliyuncs.com/kemono/image-optimizer:master-${{ env.SHA }} | ||
# registry.cn-shenzhen.aliyuncs.com/kemono/image-optimizer:latest | ||
# file: Dockerfile | ||
|
||
deploy: | ||
environment: production | ||
needs: [build] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
# deploy: | ||
# environment: production | ||
# needs: [build] | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v3 | ||
|
||
- uses: benjlevesque/[email protected] | ||
id: short-sha | ||
with: | ||
length: 7 | ||
# - uses: benjlevesque/[email protected] | ||
# id: short-sha | ||
# with: | ||
# length: 7 | ||
|
||
- name: Install fcli | ||
run: | | ||
curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-v1.0.4-linux-amd64.zip | ||
unzip fcli.zip | ||
sudo mv fcli /usr/local/bin/ | ||
# - name: Install fcli | ||
# run: | | ||
# curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-v1.0.4-linux-amd64.zip | ||
# unzip fcli.zip | ||
# sudo mv fcli /usr/local/bin/ | ||
|
||
- name: Update image version | ||
env: | ||
ALIBABA_CLOUD_ACCESS_KEY_ID: ${{ secrets.ALIYUN_ACCESS_KEY_ID }} | ||
ALIBABA_CLOUD_ACCESS_KEY_SECRET: ${{ secrets.ALIYUN_ACCESS_KEY_SECRET }} | ||
ALIBABA_CLOUD_DEFAULT_REGION: ap-southeast-1 | ||
ALIBABA_CLOUD_ACCOUNT_ID: ${{ secrets.ALIYUN_ACCOUNT_ID }} | ||
SHA: ${{ env.SHA }} | ||
run: | | ||
fcli function update -f img-opti -s kemono -g registry.ap-southeast-1.aliyuncs.com/kemono/image-optimizer:master-$SHA | ||
fcli function update -f img-opti-cleaner -s kemono -g registry.ap-southeast-1.aliyuncs.com/kemono/image-optimizer:master-$SHA -n '["./cli.sh", "clean"]' | ||
# - name: Update image version | ||
# env: | ||
# ALIBABA_CLOUD_ACCESS_KEY_ID: ${{ secrets.ALIYUN_ACCESS_KEY_ID }} | ||
# ALIBABA_CLOUD_ACCESS_KEY_SECRET: ${{ secrets.ALIYUN_ACCESS_KEY_SECRET }} | ||
# ALIBABA_CLOUD_DEFAULT_REGION: ap-southeast-1 | ||
# ALIBABA_CLOUD_ACCOUNT_ID: ${{ secrets.ALIYUN_ACCOUNT_ID }} | ||
# SHA: ${{ env.SHA }} | ||
# run: | | ||
# fcli function update -f img-opti -s kemono -g registry.ap-southeast-1.aliyuncs.com/kemono/image-optimizer:master-$SHA | ||
# fcli function update -f img-opti-cleaner -s kemono -g registry.ap-southeast-1.aliyuncs.com/kemono/image-optimizer:master-$SHA -n '["./cli.sh", "clean"]' | ||
|
||
- name: Slack Notification | ||
uses: rtCamp/action-slack-notify@v2 | ||
env: | ||
SLACK_USERNAME: 'GitHub Actions' | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
SLACK_MESSAGE: 'image-optimizer 已部署' | ||
# - name: Slack Notification | ||
# uses: rtCamp/action-slack-notify@v2 | ||
# env: | ||
# SLACK_USERNAME: 'GitHub Actions' | ||
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
# SLACK_MESSAGE: 'image-optimizer 已部署' | ||
|
||
deploy-cn: | ||
environment: production | ||
needs: [build] | ||
# needs: [build] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
@@ -103,16 +103,17 @@ jobs: | |
- name: Deploy to ECS | ||
run: | | ||
GIT_HASH=$(git rev-parse --short "$GITHUB_SHA") | ||
cp deploy/docker-compose.cn.sample.yml /tmp/docker-compose-cn-${GIT_HASH}.yml | ||
sed -i "s/{{GIT-SHA}}/${GIT_HASH}/g" /tmp/docker-compose-cn-${GIT_HASH}.yml | ||
SERVER=("img-opti-sz") | ||
parallel "ssh -o StrictHostKeyChecking=no {} 'mkdir -p /root/image-optimizer'" ::: "${SERVER[@]}" | ||
parallel scp -o StrictHostKeyChecking=no /tmp/docker-compose-cn-${GIT_HASH}.yml {}:/root/image-optimizer/docker-compose.yml ::: "${SERVER[@]}" | ||
parallel "ssh -o StrictHostKeyChecking=no {} 'cd /root/image-optimizer && docker compose up -d'" ::: "${SERVER[@]}" | ||
ssh -o StrictHostKeyChecking=no img-opti-sz 'echo "GIT_HASH=${GIT_HASH}" > /root/image-optimizer/.env' | ||
# cp deploy/docker-compose.cn.sample.yml /tmp/docker-compose-cn-${GIT_HASH}.yml | ||
# sed -i "s/{{GIT-SHA}}/${GIT_HASH}/g" /tmp/docker-compose-cn-${GIT_HASH}.yml | ||
# SERVER=("img-opti-sz") | ||
# parallel "ssh -o StrictHostKeyChecking=no {} 'mkdir -p /root/image-optimizer'" ::: "${SERVER[@]}" | ||
# parallel scp -o StrictHostKeyChecking=no /tmp/docker-compose-cn-${GIT_HASH}.yml {}:/root/image-optimizer/docker-compose.yml ::: "${SERVER[@]}" | ||
# parallel "ssh -o StrictHostKeyChecking=no {} 'cd /root/image-optimizer && docker compose up -d'" ::: "${SERVER[@]}" | ||
|
||
- name: Slack Notification | ||
uses: rtCamp/action-slack-notify@v2 | ||
env: | ||
SLACK_USERNAME: 'GitHub Actions' | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
SLACK_MESSAGE: 'image-optimizer-cn 已部署' | ||
# - name: Slack Notification | ||
# uses: rtCamp/action-slack-notify@v2 | ||
# env: | ||
# SLACK_USERNAME: 'GitHub Actions' | ||
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
# SLACK_MESSAGE: 'image-optimizer-cn 已部署' |