5307205977
Release package / release (push) Failing after 2m31s
Co-authored-by: Thanh Quy - wolf <524H0124@student.tdtu.edu.vn> Co-authored-by: Thanh Quy- wolf <524H0124@student.tdtu.edu.vn> Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Reviewed-on: #29 Co-authored-by: TaNguyenThanhQuy <tanguyenthanhquy@noreply.localhost> Co-committed-by: TaNguyenThanhQuy <tanguyenthanhquy@noreply.localhost>
113 lines
3.1 KiB
YAML
113 lines
3.1 KiB
YAML
name: Release package
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
release:
|
|
permissions:
|
|
contents: write
|
|
issues: write
|
|
pull-requests: write
|
|
id-token: write
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Setup SSH Key
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
chmod 700 ~/.ssh
|
|
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519
|
|
chmod 600 ~/.ssh/id_ed25519
|
|
|
|
ssh-keyscan -t ed25519 vps.demonkernel.io.vn >> ~/.ssh/known_hosts
|
|
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: pnpm/action-setup@v3
|
|
with:
|
|
version: latest
|
|
run_install: false
|
|
cache: true
|
|
|
|
- name: Update dependencies
|
|
run: pnpm update
|
|
|
|
- name: Format code
|
|
run: pnpm format
|
|
|
|
- name: Build application
|
|
run: pnpm build
|
|
|
|
- name: Release
|
|
env:
|
|
GITEA_USER: ${{ github.actor }}
|
|
GITEA_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
|
run: pnpm release
|
|
|
|
- name: Set Version Output
|
|
id: set_output
|
|
run: |
|
|
# Đọc version hiện tại trong package.json sau khi release
|
|
VERSION=$(node -p "require('./package.json').version")
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
|
|
- name: Log in to Gitea Container Registry
|
|
if: gitea.ref == 'refs/heads/main'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: vps.demonkernel.io.vn
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.ACCESS_TOKEN }}
|
|
|
|
- name: Prepare Docker Metadata
|
|
if: gitea.ref == 'refs/heads/main'
|
|
id: meta
|
|
run: |
|
|
# Lowercase Repository
|
|
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
|
|
|
|
RAW_VERSION="${{ steps.set_output.outputs.version }}"
|
|
VERSION_LOWER=$(echo "$RAW_VERSION" | tr '[:upper:]' '[:lower:]')
|
|
|
|
echo "repo=$REPO_LOWER" >> $GITHUB_OUTPUT
|
|
echo "version=$VERSION_LOWER" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build and Push Docker Image
|
|
if: gitea.ref == 'refs/heads/main'
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
git.demonkernel.io.vn/${{ steps.meta.outputs.repo }}:latest
|
|
git.demonkernel.io.vn/${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.version }}
|
|
|
|
- name: Commit & Push Changes
|
|
run: |
|
|
if [ -n "$(git status --porcelain)" ]&& [ "${{ github.ref_name }}" = "main" ]; then
|
|
git config --global user.name "gitea-actions"
|
|
git config --global user.email "actions-user@noreply.git.demonkernel.io.vn"
|
|
|
|
REPO_NAME="${{ gitea.repository }}"
|
|
|
|
git remote set-url origin ssh://git@vps.demonkernel.io.vn/${REPO_NAME}.git
|
|
|
|
git rm -r --cached .
|
|
git add .
|
|
git commit -m "chore: release [ci skip]"
|
|
|
|
git push
|
|
fi
|