Skip to content

Commit

Permalink
chore: refactor GitHub Actions workflows for build and deploy process
Browse files Browse the repository at this point in the history
  • Loading branch information
wu529778790 committed Oct 16, 2024
1 parent 616cd1f commit 34feb13
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 68 deletions.
68 changes: 0 additions & 68 deletions .github/workflows/build-and-deploy.yml

This file was deleted.

66 changes: 66 additions & 0 deletions .github/workflows/deploy-to-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Deploy to Docker

on:
push:
branches:
- main

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "19"

- name: Install Pnpm
run: npm install pnpm -g

- name: Install dependencies
run: pnpm install

- name: Build project
run: pnpm run build

- name: Update version and commit
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
npm version patch -m "chore(release): v%s [skip ci]"
if: ${{ always() }}

- name: Set Docker Buildx
uses: docker/setup-buildx-action@v1
if: ${{ always() }}

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
if: ${{ always() }}

- name: Get version
id: version
run: echo ::set-output name=new-version::$(npm version patch)
if: ${{ always() }}

- name: Build and push docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
wu529778790/wallpaper.shenzjd.com:${{ steps.version.outputs.new-version }}
wu529778790/wallpaper.shenzjd.com:latest
if: ${{ always() }}

- name: Push Git changes
run: |
git push
if: ${{ always() }}

0 comments on commit 34feb13

Please sign in to comment.