Skip to content

Commit

Permalink
ci: rework docker release + semantic-release
Browse files Browse the repository at this point in the history
  • Loading branch information
geokrety-bot committed Aug 8, 2023
1 parent a09a6e8 commit c466c64
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 46 deletions.
60 changes: 60 additions & 0 deletions .github/actions/docker-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Docker build
inputs:
image_name:
required: true
type: string
dockerhub_username:
required: true
type: string
dockerhub_token:
required: true
dockerfile:
type: string
default: Dockerfile
context:
type: string
default: .

runs:
using: "composite"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
${{ inputs.image_name }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ inputs.dockerhub_username }}
password: ${{ inputs.dockerhub_token }}

- name: Build and push
uses: docker/build-push-action@v4
with:
file: ${{ inputs.dockerfile }}
context: ${{ inputs.context }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
45 changes: 6 additions & 39 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,16 @@ on:
secrets:
dockerhub_token:
required: true
type: string

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
${{ inputs.image_name }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ inputs.dockerhub_username }}
password: ${{ secrets.dockerhub_token }}

- name: Build and push
uses: docker/build-push-action@v4
- uses: geokrety/geokrety-gha-workflows/.github/actions/docker-build@main
with:
file: ${{ inputs.dockerfile }}
image_name: ${{ inputs.image_name }}
dockerhub_username: ${{ inputs.dockerhub_username }}
dockerhub_token: ${{ secrets.dockerhub_token }}
dockerfile: ${{ inputs.dockerfile }}
context: ${{ inputs.context }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ on:
required: true

jobs:
pre-commit:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: geokrety/geokrety-gha-workflows/.github/actions/pre-commit@main
# pre-commit:
# if: "!contains(github.event.head_commit.message, 'skip ci')"
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: geokrety/geokrety-gha-workflows/.github/actions/pre-commit@main

semantic-release:
if: "!contains(github.event.head_commit.message, 'skip ci')"
needs: pre-commit
# needs: pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down

0 comments on commit c466c64

Please sign in to comment.