Skip to content

Commit

Permalink
Actionsでイメージをプッシュするようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
Azuki-bar committed Nov 8, 2023
1 parent f3bad26 commit 3fff4e6
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 11 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/publish-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: build and publish image

on:
push:
branches:
- "main"
- "deployment"
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

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

- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Generate tag
id: generate_tag
shell: bash
run: echo "tag=$(echo ${{ github.sha }} | cut -c1-7)-$(date +%s)" >> $GITHUB_OUTPUT

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Bake images
uses: docker/bake-action@v4
env:
TAG: ${{ steps.generate_tag.outputs.tag }}
with:
files: ./docker-bake.hcl
push: ${{ github.event_name == 'push' && startsWith( steps.extract_branch.outputs.branch , 'deployment' ) }}
set: |
*.cache-from=type=local,src=/tmp/.buildx-cache
*.cache-to=type=local,mode=min,dest=/tmp/.buildx-cache-new
provenance: false

# https://github.com/docker/build-push-action/issues/252#issuecomment-744400434
- name: Move Cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
File renamed without changes.
11 changes: 0 additions & 11 deletions backend/state-manager/Dockerfile

This file was deleted.

File renamed without changes.
File renamed without changes.

0 comments on commit 3fff4e6

Please sign in to comment.