Skip to content

Commit

Permalink
🤖优化 Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
celaraze committed Dec 14, 2023
1 parent 5c4a680 commit 57f02e3
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 99 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/ci-container-docker-hub.yml

This file was deleted.

48 changes: 0 additions & 48 deletions .github/workflows/ci-container-github-packages.yml

This file was deleted.

58 changes: 58 additions & 0 deletions .github/workflows/ci-publish-container-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI for publishing container image

on:
push:
tags:
- 'v*'

env:
REGISTRY: ghcr.io
DOCKERHUB_REGISTRY: docker.io
IMAGE_NAME: ${{ github.repository }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

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

- name: Log in to the GitHub Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.LOCAL_TOKEN }}

- name: Log in to Docker Hub
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.DOCKERHUB_REGISTRY }}
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI for Laravel test
name: CI for testing

on:
push:
Expand Down

0 comments on commit 57f02e3

Please sign in to comment.