Skip to content

Commit

Permalink
Dockerイメージのキャッシュ処理を追加。
Browse files Browse the repository at this point in the history
  • Loading branch information
Fumika Koyama committed Nov 9, 2023
1 parent 61e92cf commit 6da0930
Showing 1 changed file with 31 additions and 33 deletions.
64 changes: 31 additions & 33 deletions .github/workflows/samples-dressca-backend.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,42 +59,40 @@ jobs:
echo '# Build Result :gear:' >> $GITHUB_STEP_SUMMARY
cat build-result.txt | sed -n -e 's/^/> /p' >> $GITHUB_STEP_SUMMARY
#- name: キャッシュIDの作成
# id: imagetag
# run: |
# VARIANT=$(TZ=UTC-9 date '+%Y%m')
# # イメージのタグを作成
# NAME_IMAGE=DockerImage
# TAG="${NAME_IMAGE}:${VARIANT}"
# # キャッシュする tar アーカイブ名とパスの設定
# NAME_TAR="${NAME_IMAGE}.${VARIANT}.tar"
# PATH_TAR=${{ env.PATH_CACHE }}"/${NAME_TAR}"
# # 変数を他の run でも使えるように output
# echo "TAG=${TAG}" >> "$GITHUB_OUTPUT"
# echo "NAME_TAR=${NAME_TAR}" >> "$GITHUB_OUTPUT"
# echo "PATH_TAR=${PATH_TAR}" >> "$GITHUB_OUTPUT"

#- name: キャッシュ有効化
# id: cache
# uses: actions/cache@v3
# with:
# path: ${{ env.PATH_CACHE }}
# key: ${{ steps.imagetag.outputs.TAG }}

#- name: キャッシュがある場合にロード
# if: steps.cache.outputs.cache-hit == 'true'
# run: docker load --input ${{ steps.imagetag.outputs.PATH_TAR }}

#- name: キャッシュがない場合にイメージを保存
# if: steps.cache.outputs.cache-hit != 'true'
# run: |
# mkdir -p ${{ env.PATH_CACHE }}
# sudo docker pull mcr.microsoft.com/mssql/server:2022-latest
# sudo docker save mcr.microsoft.com/mssql/server:2022-latest -o ${{ steps.imagetag.outputs.PATH_TAR }}
- name: キャッシュIDの作成
id: imagetag
run: |
VARIANT=$(TZ=UTC-9 date '+%Y%m')
# イメージのタグを作成
NAME_IMAGE=SQLServerDockerImage
# キャッシュする tar アーカイブ名とパスの設定
NAME_TAR="${NAME_IMAGE}.${VARIANT}.tar"
PATH_TAR=${{ env.PATH_CACHE }}"/${NAME_TAR}"
# 変数を他の run でも使えるように output
echo "NAME_TAR=${NAME_TAR}" >> "$GITHUB_OUTPUT"
echo "PATH_TAR=${PATH_TAR}" >> "$GITHUB_OUTPUT"
- name: キャッシュ有効化
id: cache
uses: actions/cache@v3
with:
path: ${{ env.PATH_CACHE }}
key: ${{ steps.imagetag.outputs.NAME }}

- name: 結合テスト用にSQL Serverをセットアップ
- name: キャッシュがある場合にロード
if: steps.cache.outputs.cache-hit == 'true'
run: docker load --input ${{ steps.imagetag.outputs.PATH_TAR }}

- name: キャッシュがない場合にイメージを保存
if: steps.cache.outputs.cache-hit != 'true'
run: |
mkdir -p ${{ env.PATH_CACHE }}
sudo docker pull mcr.microsoft.com/mssql/server:2022-latest
sudo docker save mcr.microsoft.com/mssql/server:2022-latest -o ${{ steps.imagetag.outputs.PATH_TAR }}
- name: 結合テスト用にSQL Serverをセットアップ
run: |
#sudo docker pull mcr.microsoft.com/mssql/server:2022-latest
sudo docker run -e "ACCEPT_EULA=Y" \
-e "MSSQL_SA_PASSWORD=P@ssw0rd" \
-p 1433:1433 --name sql1 \
Expand Down

0 comments on commit 6da0930

Please sign in to comment.