Update .github/workflows/docker-build.yml
This commit is contained in:
parent
289654c9c8
commit
0035a51c5c
38
.github/workflows/docker-build.yml
vendored
38
.github/workflows/docker-build.yml
vendored
@ -1,16 +1,15 @@
|
|||||||
name: Build and Push Docker Image
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches: [ main ]
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
pull_request:
|
|
||||||
branches: [ main ]
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: 'Version to tag the image with (e.g., 1.0.0)'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: write # Allows tagging and releasing
|
contents: write # Allows tagging and releasing
|
||||||
@ -51,40 +50,25 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
images: ${{ github.server_url }}/${{ github.repository }}/personal-website
|
images: ${{ github.server_url }}/${{ github.repository }}/personal-website
|
||||||
tags: |
|
tags: |
|
||||||
type=semver,pattern={{version}}
|
type=raw,value=${{ github.event.inputs.version }}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
type=semver,pattern={{major}}
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=pr
|
|
||||||
type=sha
|
|
||||||
|
|
||||||
- name: Determine version
|
|
||||||
id: semver
|
|
||||||
uses: mathieudutour/github-tag-action@v6.1
|
|
||||||
with:
|
|
||||||
github_token: ${{ secrets.PACKAGE_TOKEN }}
|
|
||||||
release_branches: main
|
|
||||||
default_bump: patch
|
|
||||||
dry_run: true
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
${{ github.server_url }}/${{ github.repository }}/personal-website:latest
|
${{ github.server_url }}/${{ github.repository }}/personal-website:latest
|
||||||
${{ github.server_url }}/${{ github.repository }}/personal-website:${{ steps.semver.outputs.new_tag }}
|
${{ github.server_url }}/${{ github.repository }}/personal-website:${{ github.event.inputs.version }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: mathieudutour/github-tag-action@v6.1
|
uses: mathieudutour/github-tag-action@v6.1
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
custom_tag: ${{ github.event.inputs.version }}
|
||||||
release_branches: main
|
release_branches: main
|
||||||
default_bump: patch
|
|
||||||
create_annotated_tag: true
|
create_annotated_tag: true
|
||||||
tag_prefix: v
|
tag_prefix: v
|
||||||
|
Loading…
x
Reference in New Issue
Block a user