GitHub連携の設定方法 / GitHub Setup Guide

お酒記録では、GitHub を使って記録を仲間と共同編集したり、Webページとして公開したりできます。この機能は任意です。使わなくても、記録・写真・バーコード・マップなどアプリの全機能はご利用いただけます。

In Osake, you can use GitHub to co-edit your records with friends and publish them as a web page. This feature is optional. All core features (recording, photos, barcode, maps, etc.) work without it.

GitHub は無料で使えるソースコード・ファイル管理サービスです。ここでは、お酒記録の同期先として使うための最小限の手順を説明します。
GitHub is a free service for managing code and files. Below are the minimum steps to use it as a sync destination for Osake.

手順1: GitHubアカウントを作る / Create a GitHub account

  1. github.com/join にアクセスし、無料アカウントを作成します。
  2. 登録したユーザー名(アカウント名)を控えておきます。あとでアプリに入力します。

Go to github.com/join and create a free account. Note your username; you will enter it in the app later.

手順2: リポジトリ(保存先)を作る / Create a repository

  1. GitHub の画面右上の「+」→「New repository」を選びます。
  2. Repository name に好きな名前(例: osake-data)を入力します。
  3. 「Add a README file」にチェックを入れます(初期化が必要です)。
  4. 公開範囲は Public(だれでも閲覧可)または Private(自分と招待した人のみ)を選びます。Webで公開したい場合は Public にします。
  5. 「Create repository」を押します。

Click "+" at the top right, then "New repository". Enter a name (e.g. osake-data), check "Add a README file", choose Public or Private, and click "Create repository".

手順3: アクセストークンを発行する / Create an access token

アプリが GitHub へ記録を読み書きするために、パーソナルアクセストークン(Classic)が必要です。

  1. GitHub 右上のアイコン →「Settings」を開きます。
  2. 左メニューの一番下「Developer settings」を選びます。
  3. 「Personal access tokens」→「Tokens (classic)」を選びます。
  4. 「Generate new token」→「Generate new token (classic)」を選びます。
  5. Note に用途(例: Osake)を入力、Expiration(有効期限)を選びます。
  6. スコープは「repo」にチェックを入れます(リポジトリの読み書きに必要)。
  7. 「Generate token」を押し、表示されたトークン文字列をコピーします。
トークンは一度しか表示されません。安全な場所にコピーしておいてください。他人に知られないよう注意してください。
The token is shown only once. Copy it somewhere safe and keep it private.

Open Settings > Developer settings > Personal access tokens > Tokens (classic) > Generate new token (classic). Set a note and expiration, check the "repo" scope, generate, and copy the token.

手順4: アプリに登録する / Enter details in the app

  1. お酒記録の メニュー →「設定」→「GitHub連携」を開きます。
  2. アカウント名(GitHubのユーザー名)、トークン(手順3でコピーした文字列)、リポジトリ名(手順2で付けた名前)を入力します。
  3. フォルダは、Pages を使う場合の公開元に合わせて選びます(通常は /(root))。
  4. 「接続テスト」を押して、成功と表示されれば設定完了です。

In the app, open Menu > Settings > GitHub. Enter your account name, token, and repository name, choose the folder, then tap "Test connection".

手順5: 同期する / Sync

Tap "Sync with Website" to upload and merge records. At this point the data is only stored in GitHub. To publish it as a web page, enable GitHub Pages in step 6.

手順6: GitHub Pages を有効にして公開する / Enable GitHub Pages

GitHub Pages を有効にすると、記録を誰でも見られる Web ページとして公開できます。この設定は最初に一度だけ行えば、以降は同期するだけで内容が更新されます。

  1. 公開したいリポジトリを開き、上部の「Settings」タブを選びます。
  2. 左メニューの「Pages」を選びます。
  3. 「Build and deployment」の Source で 「Deploy from a branch」 を選びます。
  4. Branch で 「main」 を選びます。
  5. フォルダは次のどちらかを選びます(アプリの設定と必ず合わせます):
    • / (root) … アプリの「フォルダ」設定を /(root) にした場合(おすすめ)
    • /docs … アプリの「フォルダ」設定を /docs にした場合
  6. 「Save」を押します。数十秒〜数分後、ページが公開されます。
重要: GitHub Pages で選んだフォルダ(root または docs)と、アプリの「設定 > GitHub連携 > フォルダ」は同じにしてください。食い違うとページが表示されません。
Important: The folder you pick in GitHub Pages (root or docs) must match the "Folder" setting in the app. If they differ, the page will not appear.

Open the repository > Settings > Pages. Under "Build and deployment", set Source to "Deploy from a branch", Branch to "main", and choose the folder — "/ (root)" or "/docs" — to match the app's Folder setting. Click Save. The page goes live in a few minutes.

公開ページを開く / Open the published page

公開後は、メニューの「Webサイトへ」でページを開けます。URL は https://<ユーザー名>.github.io/<リポジトリ名>/ の形になります。

After publishing, use "Open Website" in the menu. The URL looks like https://<username>.github.io/<repository>/.

仲間と共同編集するには / Co-editing with friends

同じリポジトリを仲間と共有すると、それぞれの端末で登録・修正した内容を同期して最新にまとめられます。Private リポジトリの場合は、GitHub のリポジトリ設定で仲間を Collaborator として招待してください。

Share the same repository with friends to merge entries from each device. For a Private repository, invite them as Collaborators in the repository settings.