Skip to content

Commit

Permalink
ci(build-docker): don't depends on other workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
satoufuyuki committed Sep 25, 2023
1 parent b034fb1 commit 8c730c1
Showing 1 changed file with 56 additions and 3 deletions.
59 changes: 56 additions & 3 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,59 @@ on:
- "Dockerfile"

jobs:
docker:
uses: clytage/workflows/.github/workflows/docker-build.yml@main
secrets: inherit
build:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@4c0219f9ac95b02789c1075625400b2acbff50b1 # v2.9.1

- name: Login to GitHub Container Registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0
if: ${{ github.event_name != 'pull_request' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.BOT_TOKEN }}

- name: Extract tag name
id: tags
if: ${{ github.event_name == 'release' }}
run: echo ::set-output name=name::${GITHUB_REF##*/}

- name: Extract flavor
id: flavor
run: if [ "${{ github.event_name }}" = "release" ]; then echo ::set-output name=name::; else echo ::set-output name=name::-dev; fi

- id: string
uses: ASzc/change-string-case-action@07c1e24a97f0951e13f88870b99c058fcf0b14cf # v5
with:
string: ${{ github.repository }}

- name: Generate Docker image metadata
uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 # v4.6.0
id: img_meta
with:
flavor: |
latest=auto
suffix=${{ steps.flavor.outputs.name }}
images: "ghcr.io/${{ steps.string.outputs.lowercase }}"
tags: |
${{ steps.tags.outputs.name }}
latest
- name: Build and push
id: docker_build
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 # v4.1.1
with:
context: ./
tags: ${{ steps.img_meta.outputs.tags }}
labels: ${{ steps.img_meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=gha,mode=max
cache-to: type=gha,mode=max
build-args: |
COMMIT_SHA=${{ github.sha }}

0 comments on commit 8c730c1

Please sign in to comment.