From 22b209000165b8efd0bec44b85b15ff0ff60529c Mon Sep 17 00:00:00 2001 From: purin_gidai <24.m.honma.nutfes@gmail.com> Date: Sat, 28 Jun 2025 17:51:20 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[feat]=E8=87=AA=E5=8B=95=E3=83=87=E3=83=97?= =?UTF-8?q?=E3=83=AD=E3=82=A4=E3=81=AE=E3=81=9F=E3=82=81=E3=81=AErelease.y?= =?UTF-8?q?aml=E3=82=92=E4=BD=9C=E6=88=90=EF=BC=8C=E3=82=BF=E3=82=B0?= =?UTF-8?q?=E3=81=AE=E4=BD=9C=E6=88=90=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/auto-build.yml | 40 ----------------------- .github/workflows/auto-labeling.yml | 36 --------------------- .github/workflows/auto-release.yml | 49 ----------------------------- .github/workflows/release.yaml | 40 +++++++++++++++++++++++ .github/workflows/release.yml | 15 --------- 5 files changed, 40 insertions(+), 140 deletions(-) delete mode 100644 .github/workflows/auto-build.yml delete mode 100644 .github/workflows/auto-labeling.yml delete mode 100644 .github/workflows/auto-release.yml create mode 100644 .github/workflows/release.yaml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/auto-build.yml b/.github/workflows/auto-build.yml deleted file mode 100644 index fd6006b..0000000 --- a/.github/workflows/auto-build.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Build and Test - -on: - pull_request: - branches: - - main - paths: - - "view/next-project/**" - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - # Make sure the actual branch is checked out when running on pull requests - ref: ${{ github.head_ref }} - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: 16 - cache: npm - cache-dependency-path: view/next-project/package-lock.json - - name: npm install - working-directory: view/next-project - run: npm install - - name: Build - working-directory: view/next-project - run: npm run build - # - name: Prettier - # working-directory: view/next-project - # run: npm run format - # - name: Lint - # working-directory: view/next-project - # run: npm run lint:fix - - uses: stefanzweifel/git-auto-commit-action@v3.0.0 - with: - commit_message: formatted by workflow diff --git a/.github/workflows/auto-labeling.yml b/.github/workflows/auto-labeling.yml deleted file mode 100644 index ae0f61a..0000000 --- a/.github/workflows/auto-labeling.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Automatically labeling pull request. - -on: - pull_request: - types: [opened] - -jobs: - auto-labeling-pr: - runs-on: ubuntu-latest - - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v2 - - # ラベル名を取得する - - name: Get label name - id: label_name - run: | - branch_type=$(echo ${{github.head_ref}} | cut -d "/" -f1) - if [ $branch_type == 'feature' ]; then - label_name=$(echo "enhancement") - elif [ $branch_type == 'fix' ] || [ $branch_type == 'hotfix' ]; then - label_name=$(echo "bug") - else - label_name="" - fi - echo "::set-output name=label_name::$label_name" - - # PRにラベルを付与する - - name: Auto labeling - if: ${{ steps.label_name.outputs.label_name }} - run: | - number=$(echo $GITHUB_REF | sed -e 's/[^0-9]//g') - gh pr edit $number --add-label ${{ steps.label_name.outputs.label_name }} diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml deleted file mode 100644 index 1576b97..0000000 --- a/.github/workflows/auto-release.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Create release tag and release note. - -on: - push: - branches: [ main ] - -jobs: - create-release-tag: - runs-on: ubuntu-latest - - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TZ: 'Asia/Tokyo' - - steps: - - uses: actions/checkout@v2 - - # 前回のりリースタグを取得する - - name: Get previous tag - id: pre_tag - run: | - echo "::set-output name=pre_tag::$(curl -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)" - - # タグを生成する 「{YYYY.MM.DD}-{当日リリース回数}」 - - name: Generate release tag - id: release_tag - run: | - today=$(date +'%Y.%m.%d') - pre_release_date=$(echo ${{ steps.pre_tag.outputs.pre_tag }} | awk -F'-' '{print $1}') - pre_release_count=$(echo ${{ steps.pre_tag.outputs.pre_tag }} | awk -F'-' '{print $2}') - if [[ ! $pre_release_date = $today ]]; then - echo "init count" - pre_release_count=0 - fi - echo "::set-output name=release_tag::$today-$(($pre_release_count + 1))" - - # 前回リリースからの差分をもとに、リリースノートの本文を生成する - - name: Generate release note - id: release_note - run: | - echo "::set-output name=release_note::$(curl -X POST -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/${{ github.repository }}/releases/generate-notes -d '{"tag_name":"${{ steps.release_tag.outputs.release_tag }}", "previous_tag_name":"${{ steps.pre_tag.outputs.pre_tag }}"}' | jq .body | sed 's/"//g')" - - # タグを切り、リリースノートを作成する - - name: Create Release - run: | - curl -X POST \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - -d "{ \"tag_name\": \"${{ steps.release_tag.outputs.release_tag }}\", \"name\": \"${{ steps.release_tag.outputs.release_tag }}\", \"body\": \"${{ steps.release_note.outputs.release_note }}\"}" \ - https://api.github.com/repos/${{ github.repository }}/releases diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..8737bdc --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,40 @@ +name: Release action +run-name: Release action + +on: + workflow_dispatch: + inputs: + bump-level: + type: choice + options: [patch, minor, major] + required: true + description: Bump to patch or minor or major version + +jobs: + # 新しいタグをリリース + release: + timeout-minutes: 5 + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.bump.outputs.new_version }} + # GITHUB_TOKENに付与される権限を設定 + permissions: + ## readだとエラーが出るっぽい + contents: write + # 実行するステップを定義 + steps: + - uses: actions/checkout@v4 + + - id: bump + name: Bump version and tag repository + env: + USERNAME: github-actions[bot] + EMAIL: github-actions[bot]@users.noreply.github.com + BUMP_LEVEL: ${{ inputs.bump-level }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --global user.name "${USERNAME}" + git config --global user.email "${EMAIL}" + version="$(.github/scripts/bump.sh "${BUMP_LEVEL}")" + echo "New version: ${version}" + echo "new_version=${version}" >> $GITHUB_OUTPUT diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index ca39f44..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,15 +0,0 @@ -changelog: - exclude: - # リリースノートから除外したいユーザー - authors: - - github-actions - categories: - - title: New Features 🎉 - labels: - - "enhancement" - - title: Bug Fix 💊 - labels: - - "bug" - - title: Other Changes 🛠 - labels: - - "*" From 74ffe07eaf5af88ad13301f1afefdf2cb5d599c8 Mon Sep 17 00:00:00 2001 From: purin_gidai <24.m.honma.nutfes@gmail.com> Date: Sat, 28 Jun 2025 18:31:32 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[feat][feat]=E8=87=AA=E5=8B=95=E3=83=87?= =?UTF-8?q?=E3=83=97=E3=83=AD=E3=82=A4=E3=81=AE=E3=81=9F=E3=82=81=E3=81=AE?= =?UTF-8?q?release.yaml=E3=82=92=E4=BD=9C=E6=88=90=EF=BC=8Cdocker=E3=81=AB?= =?UTF-8?q?=E3=82=BF=E3=82=B0=E4=BB=98=E3=81=91=E3=81=97=E3=81=A6build?= =?UTF-8?q?=E3=81=97=E3=81=A6push=E3=81=AE=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yaml | 78 ++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8737bdc..39c227c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -38,3 +38,81 @@ jobs: version="$(.github/scripts/bump.sh "${BUMP_LEVEL}")" echo "New version: ${version}" echo "new_version=${version}" >> $GITHUB_OUTPUT + + # リリースしたタグを元にdockerイメージをビルドしてpushする + build-and-push: + needs: release + runs-on: ubuntu-latest + strategy: + matrix: + include: + - context: api + dockerfile: api/Dockerfile + image: seeds/seeds-api + - context: view + dockerfile: view/Dockerfile + image: seeds/seeds-view + + steps: + # リポジトリのチェックアウト + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Create .env file from Secrets + run: echo "${{ secrets.PROD_ENV }}" > .env + + # .envファイルの内容をbuild-argsとして利用できるように整形 + - name: Generate build args from .env + id: build_args + run: | + echo "ARGS<> $GITHUB_OUTPUT + cat .env >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + # arm64アーキテクチャのビルドを行う場合は、以下のコメントアウトを解除してください + # # QEMUエミュレーションのセットアップ + # - name: Set up QEMU for multi-arch + # uses: docker/setup-qemu-action@v3 # QEMU エミュレーション + + # Docker Buildxのセットアップ + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + install: true + buildkitd-flags: --debug + + - name: Docker Login + uses: docker/login-action@v3 + with: + registry: ${{ secrets.HARBOR_REG }} + username: ${{ secrets.HARBOR_USERNAME }} + password: ${{ secrets.HARBOR_PASS }} + + # Docker Buildxを使用してマルチアーキテクチャのDockerイメージをビルドし、プッシュ + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: ${{ matrix.context }} + file: ${{ matrix.dockerfile }} + platforms: linux/amd64 + # platforms: linux/arm64,linux/amd64 + pull: true + push: true + tags: | + ${{ secrets.HARBOR_REG }}/${{ matrix.image_name }}:${{ needs.release.outputs.tag }} + ${{ secrets.HARBOR_REG }}/${{ matrix.image_name }}:latest + build-args: ${{ steps.build_args.outputs.ARGS }} + cache-from: | + type=gha,scope=${{ matrix.image_name }}-cache + type=registry,ref=${{ secrets.HARBOR_REG }}/${{ matrix.image_name }}:cache + cache-to: | + type=gha,mode=max,scope=${{ matrix.image_name }}-cache + type=registry,ref=${{ secrets.HARBOR_REG }}/${{ matrix.image_name }}:cache,mode=max,image-manifest=true + + # Docker Buildxのキャッシュをプルーニング + - name: Prune Buildx builder and caches + if: always() + run: | + docker buildx prune --all --force From 8d80ae03eb77111dd87381c937082d65d18a5247 Mon Sep 17 00:00:00 2001 From: purin_gidai <24.m.honma.nutfes@gmail.com> Date: Wed, 2 Jul 2025 14:41:46 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[fix]=E4=B8=8D=E5=BF=85=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E9=83=A8=E5=88=86=E3=81=8C=E3=81=82=E3=81=A3=E3=81=9F=E3=81=AE?= =?UTF-8?q?=E3=81=A7=EF=BC=8C=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 39c227c..07e7237 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -31,7 +31,7 @@ jobs: USERNAME: github-actions[bot] EMAIL: github-actions[bot]@users.noreply.github.com BUMP_LEVEL: ${{ inputs.bump-level }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git config --global user.name "${USERNAME}" git config --global user.email "${EMAIL}"