mirror of https://github.com/1N3/Sn1per.git
test build and push
This commit is contained in:
parent
2cabdb512f
commit
971038eebb
|
|
@ -1,52 +1,48 @@
|
||||||
name: Build and Push docker
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- development
|
|
||||||
- feat*
|
|
||||||
- gh-action
|
|
||||||
tags:
|
|
||||||
- "v*"
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: ghcr.io
|
|
||||||
RAW_IMAGE_NAME: ${{ github.repository }}
|
|
||||||
IMAGE_NAME: ${RAW_IMAGE_NAME,,} # Convert repository name to lowercase
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy-docker-hello-world:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Docker meta
|
- name: Set up Docker Buildx
|
||||||
id: meta
|
uses: docker/setup-buildx-action@v1
|
||||||
uses: docker/metadata-action@v4
|
|
||||||
with:
|
|
||||||
images: ${{ env.REGISTRY}}/${{ env.IMAGE_NAME }} # Use the original name for metadata
|
|
||||||
flavor: latest=true
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=pr
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
|
|
||||||
- name: Login to image repository
|
- name: Build and push Docker image
|
||||||
uses: docker/login-action@v2
|
id: docker_build
|
||||||
with:
|
|
||||||
registry: ${{ env.REGISTRY }}
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: Dockerfile.base
|
file: Dockerfile.base
|
||||||
push: ${{ github.ref_type == 'tag' || github.ref_name == 'main' || startsWith(github.ref_name, 'feat-')}}
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
|
- name: Docker image metadata
|
||||||
|
id: image_meta
|
||||||
|
uses: docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: ghcr.io/${{ github.repository }}
|
||||||
|
flavor: latest=true
|
||||||
|
tags: |
|
||||||
|
type=sha
|
||||||
|
|
||||||
|
- name: Login to ghcr.io
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Push metadata to image
|
||||||
|
run: docker push ghcr.io/${{ github.repository }}
|
||||||
|
|
||||||
|
- name: Push tags to image
|
||||||
|
run: docker push ${{ steps.image_meta.outputs.tags }}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue