update station config #48
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
name: main-build-deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repositories | |
uses: actions/checkout@v2 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: cn-northwest-1 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Setup NodeJS | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16.10.0 | |
- name: NPM install | |
run: | | |
npm i | |
- name: Build | |
run: npm run build | |
- name: Set short sha | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Build, tag, and push image to Amazon ECR | |
id: build-image | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: my-ecr-repo | |
IMAGE_TAG: ${{ steps.vars.outputs.sha_short }} | |
run: | | |
npm run docker-ci | |
- name: Deploy the bot | |
uses: garygrossgarten/github-action-ssh@release | |
with: | |
command: | | |
sed -i -r 's/juzi-marketing-bot:[0-9a-z]{7}/juzi-marketing-bot:${{ steps.vars.outputs.sha_short }}/g' /root/docker-compose.yml | |
$(aws ecr get-login --no-include-email --region cn-northwest-1) | |
docker-compose up -d | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
privateKey: ${{ secrets.PRIVATE_KEY}} | |
outputs: | |
version: ${{ github.sha }} |