Skip to content

chore(deps): update python docker tag to v3.11.5 #58

chore(deps): update python docker tag to v3.11.5

chore(deps): update python docker tag to v3.11.5 #58

Workflow file for this run

name: Test Dockerfile
on:
pull_request:
branches:
- main
- master
paths:
- "dockerfiles/**"
- ".github/workflows/dockerfile-test.yml"
jobs:
list-files:
runs-on: ubuntu-latest
outputs:
files: ${{ steps.list-files.outputs.files }}
steps:
- name: 🛎 Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: 📄 List Dockefile files
id: list-files
run: |
# git diff --name-only の結果をもとに、Dockerfile 拡張子のファイルを取得して、JSON配列として $GITHUB_OUTPUT に files として出力する
echo "[$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -E 'Dockerfile$' | sed -r -e 's/dockerfiles\/(.+).Dockerfile/\1/' -e 's/^/"/' -e 's/$/",/' | tr -d '\n' | sed -e 's/,$//')]"
echo "files=[$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -E 'Dockerfile$' | sed -r -e 's/dockerfiles\/(.+).Dockerfile/\1/' -e 's/^/"/' -e 's/$/",/' | tr -d '\n' | sed -e 's/,$//')]" >> $GITHUB_OUTPUT
test:
runs-on: ubuntu-latest
needs: list-files
strategy:
matrix:
file: ${{ fromJson(needs.list-files.outputs.files) }}
fail-fast: false
steps:
- name: 🛎 Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: 🧪 Test
id: test
run: |
# dockerfiles/tests/<File>/ ディレクトリが存在するか確認し、存在する場合は、そのディレクトリに移動して docker build を実行する
# <File> は拡張子を除いたファイル名
if [ -d "dockerfiles/tests/${{ matrix.file }}" ]; then
cp dockerfiles/${{ matrix.file }}.Dockerfile dockerfiles/tests/${{ matrix.file }}/Dockerfile
cd dockerfiles/tests/${{ matrix.file }}
docker build -t test .
docker run --name test test
docker export -o test.tar test
docker rm test
echo "success=true" >> $GITHUB_OUTPUT
else
echo "success=false" >> $GITHUB_OUTPUT
fi
- name: 📦 Upload artifact
uses: actions/upload-artifact@v3
if: steps.test.outputs.success == 'true'
with:
name: ${{ matrix.file }}.tar
path: |
dockerfiles/tests/${{ matrix.file }}/test.tar