test docker build

This commit is contained in:
Darren 2023-12-11 10:02:01 +08:00 committed by GitHub
parent 04480cabed
commit 14ed83e04e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 26 deletions

View file

@ -3,7 +3,6 @@
# When version include "-", it not divide version and build ony one test image # When version include "-", it not divide version and build ony one test image
# It have enable multiPlatform, you add more platform at platform: linux/amd64... # It have enable multiPlatform, you add more platform at platform: linux/amd64...
# If you add more paths for trigger, please update app_list= at set-matrix for it also # If you add more paths for trigger, please update app_list= at set-matrix for it also
# MEDIA_FROM environment: source | artifact, when use source get from contentful and oss, use artifact download media-latest from Websoft9 artifact
name: Build image to DockerHub name: Build image to DockerHub
@ -16,6 +15,8 @@ on:
jobs: jobs:
setup: setup:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -26,20 +27,13 @@ jobs:
run: | run: |
git diff --name-only HEAD^ HEAD git diff --name-only HEAD^ HEAD
changed_files=$(git diff --name-only HEAD^ HEAD) changed_files=$(git diff --name-only HEAD^ HEAD)
app_list=$(echo "$changed_files" | grep -E 'apps/.*/(Dockerfile)' | awk -F'/' '{print $2}' | sort | uniq) app_list=$(echo "$changed_files" | grep -E 'docker/.*/(Dockerfile)' | awk -F'/' '{print $2}' | sort | uniq)
if [ -z "$app_list" ]; then app_list_json=$(echo $app_list | jq -R -s -c 'split(" ")')
app_list_json='[]'
else
app_list_json=$(echo $app_list | jq -R -s -c 'split(" ")')
fi
echo "::set-output name=matrix::{\"app\": $app_list_json}" echo "::set-output name=matrix::{\"app\": $app_list_json}"
build: build:
needs: setup needs: setup
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
# You can set it to choice where download from
MEDIA_FROM: "source"
strategy: strategy:
matrix: ${{fromJson(needs.setup.outputs.matrix)}} matrix: ${{fromJson(needs.setup.outputs.matrix)}}
steps: steps:
@ -75,10 +69,8 @@ jobs:
echo "DIRECTORY=docker/$APP" >> $GITHUB_ENV echo "DIRECTORY=docker/$APP" >> $GITHUB_ENV
echo "README=docker/$APP/README.md" >> $GITHUB_ENV echo "README=docker/$APP/README.md" >> $GITHUB_ENV
##begin----------- special task for apphub----------------------# ##------------ special task for apphub begin----------------------#
- name: Trigger media.yml workflow - name: Trigger media.yml workflow
if: env.APP == 'apphub' && env.MEDIA_FROM == 'source'
uses: mathze/workflow-dispatch-action@v1.1.0 uses: mathze/workflow-dispatch-action@v1.1.0
id: startAndWaitWorkflow id: startAndWaitWorkflow
with: with:
@ -86,25 +78,20 @@ jobs:
token: ${{github.token}} token: ${{github.token}}
run-id: dummy run-id: dummy
wait-interval: PT10S wait-interval: PT10S
if: env.APP == 'apphub'
- name: Wait for Workflow - name: Reuse workflow run id
if: env.APP == 'apphub' && env.MEDIA_FROM == 'source'
run: "echo ${{ steps.startAndWaitWorkflow.outputs.run-id }}" run: "echo ${{ steps.startAndWaitWorkflow.outputs.run-id }}"
if: env.APP == 'apphub'
- name: Download media.zip from action artifact
- name: Download media.zip from artifacts
uses: Legit-Labs/action-download-artifact@v2 uses: Legit-Labs/action-download-artifact@v2
if: env.APP == 'apphub' && env.MEDIA_FROM == 'source'
with: with:
workflow: media.yml workflow: media.yml
name: media name: media
path: ${{env.DIRECTORY}} path: ${{env.DIRECTORY}}
if: env.APP == 'apphub'
- name: Download media-latest.zip from Websoft9 artifact ##------------ special task for apphub end----------------------#
if: env.MEDIA_FROM == 'artifact'
run: |
curl -o media.zip https://w9artifact.blob.core.windows.net/release/websoft9/plugin/media/media-latest.zip
##end------------ special task for apphub ---------------------#
- name: Build & push Docker image - name: Build & push Docker image
uses: mr-smithers-excellent/docker-build-push@v6 uses: mr-smithers-excellent/docker-build-push@v6

View file

@ -1,5 +1,5 @@
# This file can running at actions # This file can running at actions
# modify time: 202312110950, you can modify here to trigger Docker Build action # modify time: 202312111001, you can modify here to trigger Docker Build action
FROM python:3.10-slim-bullseye FROM python:3.10-slim-bullseye