Skip to content

Commit

Permalink
feat: change workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lcxfs1991 committed Jan 23, 2024
1 parent a842ba6 commit 5da2515
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 52 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Docker Image CI

on:
push:
branches: [ "cn" ]

jobs:

build:

runs-on: ubuntu-latest

steps:

- name: Checkout Github Repo
uses: actions/checkout@v4
with:
# submodules: recursive
submodules: 'true'
token: ${{ secrets.CHECKOUT_REPO_TOKEN }}

- name: Set Branch Name
run: echo "BRANCH_NAME=$(echo $GITHUB_REF | sed 's/refs\/heads\///')" >> $GITHUB_ENV

- name: Set Timestamp
run: echo "TIMESTAMP=$(date +%s%3N)" >> $GITHUB_ENV

- name: Fetch default.conf
uses: valitydev/action-download-file@v1
with:
url: https://raw.githubusercontent.com/lcxfs1991/docschina-deployment/main/markdown-it/default.conf
target-path: .

- name: Fetch Dockerfile
uses: valitydev/action-download-file@v1
with:
url: https://raw.githubusercontent.com/lcxfs1991/docschina-deployment/main/markdown-it/Dockerfile
target-path: .


- name: Build docs
uses: actions/setup-node@v4
with:
node-version: 16

- run: npm i && npm run build

- name: Docker build
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ccr.ccs.tencentyun.com
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64
tags: ccr.ccs.tencentyun.com/docschina/markdown-it:${{ env.BRANCH_NAME }}-${{ env.TIMESTAMP }}

- name: Deployment
uses: TencentCloud/cli-action@v1
with:
secret_id: ${{ secrets.SECRET_ID }}
secret_key: ${{ secrets.SECRET_KEY }}
region: ${{ secrets.LIGHTHOUSE_REGION }}
commands: tat InvokeCommand --cli-unfold-argument --region ap-shanghai --CommandId cmd-boc4aaiw --InstanceIds lhins-nkwfootc --Parameters '{"deployment":"markdown-it","image":"ccr.ccs.tencentyun.com/docschina/markdown-it:${{ env.BRANCH_NAME }}-${{ env.TIMESTAMP }}"}'
output_format: json
52 changes: 0 additions & 52 deletions .github/workflows/main.yml

This file was deleted.

0 comments on commit 5da2515

Please sign in to comment.