Release 1.0.9 #1531
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 CI/CD | |
on: | |
pull_request: | |
branches: ['main'] | |
types: ['closed'] | |
permissions: | |
contents: read | |
jobs: | |
check-branch: | |
if: contains(github.head_ref, 'release') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check branch | |
run: | | |
echo "This is a release branch" | |
check-merged: | |
needs: check-branch | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check merged | |
run: | | |
echo "This is a merged release branch" | |
extract-version: | |
needs: check-merged | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.extract-version.outputs.version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Extract version | |
id: extract-version | |
run: | | |
echo "version=$(echo "$(git show -s --format=%s)" | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')" >> "$GITHUB_OUTPUT" | |
CI: | |
name: Main Server CI Check | |
needs: extract-version | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 16 | |
- name: Check version | |
run: | | |
echo "This release version: ${{ needs.extract-version.outputs.version }}" | |
- name: Install dependencies | |
run: npm install | |
- name: Prettier | |
run: npm run format | |
- name: Lint | |
run: npm run lint | |
- name: Build Test | |
run: npm run build | |
CD: | |
name: Main Server CD Check | |
needs: [CI, extract-version] | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Build and push Docker image | |
run: | | |
touch .env.production | |
echo "${{ secrets.MAIN_ENV }}" >> .env.production | |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.MAIN_DOCKER_IMAGE }}:${{ needs.extract-version.outputs.version }} . | |
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.MAIN_DOCKER_IMAGE }}:${{ needs.extract-version.outputs.version }} | |
- name: Deploy | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.MAIN_HOST }} | |
port: 4222 | |
username: ${{ secrets.MAIN_USERNAME }} | |
password: ${{ secrets.MAIN_KEY }} | |
script: | | |
docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.MAIN_DOCKER_IMAGE }}:${{ needs.extract-version.outputs.version }} | |
docker stop ${{ secrets.MAIN_DOCKER_IMAGE }} | |
docker rm -f ${{ secrets.MAIN_DOCKER_IMAGE }} | |
docker run --name=${{ secrets.MAIN_DOCKER_IMAGE }} -d -p 3000:3000 ${{ secrets.DOCKER_USERNAME }}/${{ secrets.MAIN_DOCKER_IMAGE }}:${{ needs.extract-version.outputs.version }} | |
docker container prune -f | |
docker image prune -f | |
create-release: | |
needs: [CD, extract-version] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: create release | |
uses: ncipollo/[email protected] | |
with: | |
tag: ${{ needs.extract-version.outputs.version }} | |
name: ${{ needs.extract-version.outputs.version }} |