update github action

This commit is contained in:
aichy126 2022-10-18 17:52:24 +08:00
parent e7f09daf07
commit db9afb6445
2 changed files with 64 additions and 9 deletions

View File

@ -0,0 +1,50 @@
name: Build Docker Hub Image
on:
push:
branches: [ "main" ]
tags:
- 2.*
- 1.*
- 0.*
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v3
with:
images: answerdev/answer
tags: |
type=raw,value=latest
# branch event
type=ref,enable=true,priority=600,prefix=,suffix=,event=branch
# tag event
type=ref,enable=true,priority=600,prefix=,suffix=,event=tag
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@ -1,8 +1,12 @@
name: Build Docker Image
name: Build GitHub Image
on:
push:
branches: [ "main" ]
tags:
- 2.*
- 1.*
- 0.*
pull_request:
branches: [ "main" ]
@ -39,6 +43,7 @@ jobs:
tags: |
type=raw,value=latest
- name: Build Img
uses: docker/build-push-action@v3
with:
@ -49,12 +54,12 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: build to hub.docker
run: |
docker build -t answerdev/answer -f ./Dockerfile .
- name: Login to hub.docker Registry
run: docker login --username=${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}
- name: Push Image to hub.docker
run: |
docker push answerdev/answer
# - name: build to hub.docker
# run: |
# docker build -t answerdev/answer -f ./Dockerfile .
# - name: Login to hub.docker Registry
# run: docker login --username=${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}
# - name: Push Image to hub.docker
# run: |
# docker push answerdev/answer