Skip to content

Commit

Permalink
feat: docker 镜像自动推送
Browse files Browse the repository at this point in the history
  • Loading branch information
SALTWOOD committed May 25, 2024
1 parent dcdd80f commit 3e8b077
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 2 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/on-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Push image on dev

on:
push:
branches: ["dev"]
workflow_dispatch:

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
if: false
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set environment
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: saltwood233/csharp-openbmclapi

- name: Build and push Docker image
id: push
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
push: true
tags: saltwood233/csharp-openbmclapi:dev
42 changes: 42 additions & 0 deletions .github/workflows/on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Push image on master

on:
push:
branches: ["master"]
workflow_dispatch:

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set environment
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: saltwood233/csharp-openbmclapi

- name: Build and push Docker image
id: push
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
push: true
tags: saltwood233/csharp-openbmclapi
43 changes: 43 additions & 0 deletions .github/workflows/on-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Push image on tag

on:
push:
tags:
- v*
workflow_dispatch:

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set environment
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: saltwood233/csharp-openbmclapi

- name: Build and push Docker image
id: push
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
push: true
tags: saltwood233/csharp-openbmclapi:${{env.RELEASE_VERSION}}
2 changes: 0 additions & 2 deletions CSharp-OpenBMCLAPI/Modules/Storage/IStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace CSharpOpenBMCLAPI.Modules.Storage
{
/// <summary>
Expand Down

0 comments on commit 3e8b077

Please sign in to comment.