Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

コンテナイメージのビルド & 保管をGitHub Container Registryにする #77

Merged
merged 14 commits into from
Apr 9, 2023
50 changes: 50 additions & 0 deletions .github/workflows/docker-io.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish Docker image (io)

on:
push:
tags:
- "**"

workflow_dispatch:

jobs:
push_to_registry:
name: Push Docker image to GitHub Container Registry
runs-on: ubuntu-22.04
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latest を使うとlatestで使用されるバージョンが変わると厄介するかもしれないので。

if: github.repository == 'MisskeyIO/misskey'
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
Laica-Lunasys marked this conversation as resolved.
Show resolved Hide resolved
with:
platforms: linux/amd64
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/misskeyio/misskey
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare image tags
run: |
echo "FORMATTED_BRANCH_NAME=$(echo ${{ github.ref_name }} | sed -e 's/\//-/g' )" >> $GITHUB_ENV
Comment on lines +34 to +36
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

イメージタグにブランチ名を使うようにしてる。
んだけど、イメージタグには / が使えないので - に置き換えておく
(ブランチ名に / を使うなという話でもある)

- name: Build and Push to GitHub Container Registry
uses: docker/build-push-action@v4
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
push: true
platforms: ${{ steps.buildx.outputs.platforms }}
provenance: false
labels: ${{ env.FORMATTED_BRANCH_NAME }}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/misskeyio/misskey:latest
ghcr.io/misskeyio/misskey:${{ env.FORMATTED_BRANCH_NAME }}
Comment on lines +49 to +50
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latest と一緒にブランチ名をタグ付けしておく (ブランチ名 or タグ付けしていればタグ名)