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..07e7237 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,118 @@ +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 + + # リリースしたタグを元に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 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: - - "*"