From d881617a7f874f6b384124c216a3ce7717565867 Mon Sep 17 00:00:00 2001 From: sousuke0422 Date: Sat, 17 Feb 2024 01:18:36 +0900 Subject: [PATCH 1/6] feat(ci): wip docker image publish from ayuskey-legacy --- .github/workflows/docker-publish-develop.yml | 118 +++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 .github/workflows/docker-publish-develop.yml diff --git a/.github/workflows/docker-publish-develop.yml b/.github/workflows/docker-publish-develop.yml new file mode 100644 index 0000000000..f8df8cbb78 --- /dev/null +++ b/.github/workflows/docker-publish-develop.yml @@ -0,0 +1,118 @@ +name: Docker ALBS (develop) +# Ayuskey-Legacy Build System + +on: + push: + # Publish `v11-lts` as Docker `latest` image. + branches: + - develop + + # Publish `v1.2.3` tags as releases. +# no tag +# tags: +# - 11.37.1* + + # Run tests for any PRs. + pull_request: + +env: + # TODO: Change variable to your image's name. +# IMAGE_NAME_LTS: ayuskey-lts # not stable +# IMAGE_NAME_LATEST: ayuskey-latest # todo + IMAGE_NAME: ayuskey10 # (仮) + +jobs: + # Run tests. + # See also https://docs.docker.com/docker-hub/builds/automated-testing/ +# dockle.ymlなどで十分 +# test: +# runs-on: ubuntu-22.04 +# +# steps: +# - uses: actions/checkout@v3 +# with: +# submodules: true +# +# - name: Run tests +# run: | +# if [ -f docker-compose.test.yml ]; then +# docker-compose --file docker-compose.test.yml build +# docker-compose --file docker-compose.test.yml run sut +# else +# docker build . --file Dockerfile +# fi + + # Push image to GitHub Packages. + # See also https://docs.docker.com/docker-hub/builds/ + push: + # Ensure test job passes before pushing image. + # needs: test + + runs-on: ubuntu-22.04 + if: github.event_name == 'push' + + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Build image + run: docker build . --file Dockerfile --tag $IMAGE_NAME #--tag $IMAGE_NAME_LATEST #--tag $IMAGE_NAME_LTS + + - name: Log into registry + #run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + +# - name: Push image (lts) +# run: | +# #IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME_LTS +# IMAGE_ID=ghcr.io/teamblackcrystal/$IMAGE_NAME_LTS +# +# # Change all uppercase to lowercase +# IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') +# +# # Strip git ref prefix from version +# VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') +# +# # Strip "v" prefix from tag name +# [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') +# +# # Use Docker `latest` tag convention +# [ "$VERSION" == "v11-lts" ] && VERSION=latest +# +# echo IMAGE_ID=$IMAGE_ID +# echo VERSION=$VERSION +# +# docker tag $IMAGE_NAME_LTS $IMAGE_ID:$VERSION +# docker push $IMAGE_ID:$VERSION + + - name: Push image (version) + run: | + #IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME + IMAGE_ID=ghcr.io/teamblackcrystal/$IMAGE_NAME + + # Change all uppercase to lowercase + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + + # Strip git ref prefix from version + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + + # Strip "v" prefix from tag name + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + + # Use Docker `latest` tag convention + [ "$VERSION" == "v11-lts" ] && VERSION=latest + + # developはコミットハッシュで + # まともにタブもつけてないしこれで十分 (本当は"git describe --tags HEAD"の方が人間にもわかりやすいかも) + VERSION=$(git rev-parse --short HEAD) + + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + + docker tag $IMAGE_NAME $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION From 7bcd5696b7a45bbb13bf0e6b27740b7530f75b96 Mon Sep 17 00:00:00 2001 From: sousuke0422 Date: Sat, 17 Feb 2024 01:25:23 +0900 Subject: [PATCH 2/6] chore: add org/repo check --- .github/workflows/docker-publish-develop.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish-develop.yml b/.github/workflows/docker-publish-develop.yml index f8df8cbb78..87a748db9d 100644 --- a/.github/workflows/docker-publish-develop.yml +++ b/.github/workflows/docker-publish-develop.yml @@ -49,7 +49,9 @@ jobs: # needs: test runs-on: ubuntu-22.04 - if: github.event_name == 'push' + if: >- + github.event_name == 'push' || + github.repository == 'TeamBlackCrystal/ayuskey' # 他で使うときはここを書き換える permissions: contents: read From 10913e1eeedf561887e0d0fa425d41e7585dc534 Mon Sep 17 00:00:00 2001 From: sousuke0422 Date: Sat, 17 Feb 2024 01:27:13 +0900 Subject: [PATCH 3/6] fix: syntax --- .github/workflows/docker-publish-develop.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish-develop.yml b/.github/workflows/docker-publish-develop.yml index 87a748db9d..b8b7915b96 100644 --- a/.github/workflows/docker-publish-develop.yml +++ b/.github/workflows/docker-publish-develop.yml @@ -51,7 +51,8 @@ jobs: runs-on: ubuntu-22.04 if: >- github.event_name == 'push' || - github.repository == 'TeamBlackCrystal/ayuskey' # 他で使うときはここを書き換える + github.repository == 'TeamBlackCrystal/ayuskey' + # 他で使うときは↑を書き換える permissions: contents: read From 44681080b371d2b5c6c7e3a2cbe7c9f66d4fd325 Mon Sep 17 00:00:00 2001 From: sousuke0422 Date: Sat, 17 Feb 2024 11:12:45 +0900 Subject: [PATCH 4/6] chore: support akariskey --- .github/workflows/docker-publish-develop.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish-develop.yml b/.github/workflows/docker-publish-develop.yml index b8b7915b96..3a232cd51b 100644 --- a/.github/workflows/docker-publish-develop.yml +++ b/.github/workflows/docker-publish-develop.yml @@ -17,10 +17,14 @@ on: env: # TODO: Change variable to your image's name. + # ayuskey # IMAGE_NAME_LTS: ayuskey-lts # not stable # IMAGE_NAME_LATEST: ayuskey-latest # todo IMAGE_NAME: ayuskey10 # (仮) + # akariskey + AKARI_IMAGE_NAME: akariskey + jobs: # Run tests. # See also https://docs.docker.com/docker-hub/builds/automated-testing/ @@ -51,7 +55,8 @@ jobs: runs-on: ubuntu-22.04 if: >- github.event_name == 'push' || - github.repository == 'TeamBlackCrystal/ayuskey' + github.repository == 'TeamBlackCrystal/ayuskey' || + github.repository == 'AkariNext/akariskey' # 他で使うときは↑を書き換える permissions: @@ -97,6 +102,7 @@ jobs: run: | #IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME IMAGE_ID=ghcr.io/teamblackcrystal/$IMAGE_NAME + [[ "${{github.repository}}" == "AkariNext/akariskey" ]] && IMAGE_ID=ghcr.io/akarinext/$AKARI_IMAGE_NAME && IMAGE_NAME=$AKARI_IMAGE_NAME && echo "akariskey mode" # Change all uppercase to lowercase IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') From 3685fbd44500872c36812251c3d39cf9018354b8 Mon Sep 17 00:00:00 2001 From: sousuke0422 Date: Sat, 17 Feb 2024 11:46:00 +0900 Subject: [PATCH 5/6] fix: akariskey build --- .github/workflows/docker-publish-develop.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish-develop.yml b/.github/workflows/docker-publish-develop.yml index 3a232cd51b..626a5fe103 100644 --- a/.github/workflows/docker-publish-develop.yml +++ b/.github/workflows/docker-publish-develop.yml @@ -69,7 +69,9 @@ jobs: submodules: true - name: Build image - run: docker build . --file Dockerfile --tag $IMAGE_NAME #--tag $IMAGE_NAME_LATEST #--tag $IMAGE_NAME_LTS + run: | + [[ "${{github.repository}}" == "AkariNext/akariskey" ]] && IMAGE_NAME=$AKARI_IMAGE_NAME && echo "akariskey mode" + docker build . --file Dockerfile --tag $IMAGE_NAME #--tag $IMAGE_NAME_LATEST #--tag $IMAGE_NAME_LTS - name: Log into registry #run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin From cd84061813d072a2c705e10172d6c86b6e7408aa Mon Sep 17 00:00:00 2001 From: sousuke0422 Date: Sat, 17 Feb 2024 11:54:42 +0900 Subject: [PATCH 6/6] chore: no pr --- .github/workflows/docker-publish-develop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish-develop.yml b/.github/workflows/docker-publish-develop.yml index 626a5fe103..f501c82f21 100644 --- a/.github/workflows/docker-publish-develop.yml +++ b/.github/workflows/docker-publish-develop.yml @@ -13,7 +13,7 @@ on: # - 11.37.1* # Run tests for any PRs. - pull_request: + #pull_request: env: # TODO: Change variable to your image's name.