Use image hosted on ghcr.io #24
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Build mysql container" | |
on: | |
pull_request: | |
paths: | |
- "containers/mysql/**" | |
- ".github/workflows/build-mysql-container.yaml" | |
- "!**.md" | |
push: | |
branches: | |
- 'main' | |
paths: | |
- "containers/mysql/**" | |
- ".github/workflows/build-mysql-container.yaml" | |
- "!**.md" | |
jobs: | |
filter: | |
runs-on: ubuntu-20.04 | |
outputs: | |
mysql-versions: ${{ steps.filter.outputs.mysql-versions }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: filter | |
id: filter | |
working-directory: containers | |
run: | | |
array=() | |
for dir in $(find ./mysql -mindepth 1 -type d -printf '%f\n'); do | |
result=$(./tag_exists moco/mysql "mysql/$dir") | |
if [ "$result" = ng ]; then | |
array+=( "$dir" ) | |
fi | |
done | |
json_output=$(printf '%s\n' "${array[@]}" | jq -R . | jq -s . | jq -c .) | |
echo "mysql-versions=$json_output" >> "$GITHUB_OUTPUT" | |
tests: | |
if: github.event_name == 'pull_request' | |
needs: filter | |
runs-on: ${{ vars.IMAGE_BUILD_RUNNER || 'ubuntu-20.04' }} | |
strategy: | |
matrix: | |
mysql-version: ${{ fromJson(needs.filter.outputs.mysql-versions) }} | |
k8s-version: [ "1.27.1" ] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: docker/setup-buildx-action@v2 | |
with: | |
driver: docker # refs: https://github.com/docker/build-push-action/issues/321 | |
- name: Check TAG file | |
working-directory: containers | |
run: | | |
result="$(./tag_exists moco/mysql mysql/${{ matrix.mysql-version }})" | |
if [ "$result" = ok ]; then | |
exit 1 | |
fi | |
echo "TAG=$(cat ./mysql/${{ matrix.mysql-version }}/TAG)" >> $GITHUB_ENV | |
- uses: docker/build-push-action@v4 | |
with: | |
context: containers/mysql/${{ matrix.mysql-version }}/. | |
push: false | |
load: true | |
tags: | | |
ghcr.io/cybozu-go/moco/mysql:${{ env.TAG }} | |
ghcr.io/cybozu-go/moco/mysql:${{ matrix.mysql-version }} | |
- name: Install Container Structure Tests | |
run: | | |
VERSION=v1.15.0 | |
curl -LO "https://storage.googleapis.com/container-structure-test/$VERSION/container-structure-test-linux-amd64" \ | |
&& chmod +x container-structure-test-linux-amd64 \ | |
&& sudo mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test | |
- name: Run Container Structure Tests | |
run: | | |
container-structure-test test --image ghcr.io/cybozu-go/moco/mysql:${{ matrix.mysql-version }} --config ./containers/mysql/${{ matrix.mysql-version }}/container-structure-test.yaml | |
- uses: ./.github/workflows/e2e.yaml | |
with: | |
k8s-version: ${{ matrix.k8s-version }} | |
mysql-version: ${{ matrix.mysql-version }} | |
use-local-mysql-image: true | |
build: | |
if: github.ref == 'refs/heads/main' | |
needs: filter | |
runs-on: ${{ vars.IMAGE_BUILD_RUNNER || 'ubuntu-20.04' }} | |
strategy: | |
matrix: | |
mysql-version: ${{ fromJson(needs.filter.outputs.mysql-versions) }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: docker/setup-qemu-action@v2 | |
- uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check TAG file | |
working-directory: containers | |
run: | | |
result="$(./tag_exists moco/mysql mysql/${{ matrix.mysql-version }})" | |
if [ "$result" = ok ]; then | |
exit 1 | |
fi | |
echo "TAG=$(cat ./mysql/${{ matrix.mysql-version }}/TAG)" >> $GITHUB_ENV | |
- uses: docker/build-push-action@v4 | |
with: | |
context: containers/mysql/${{ matrix.mysql-version }}/. | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: | | |
ghcr.io/cybozu-go/moco/mysql:${{ env.TAG }} | |
ghcr.io/cybozu-go/moco/mysql:${{ matrix.mysql-version }} |