Skip to content

Commit

Permalink
test docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
chendelin1982 authored Dec 11, 2023
1 parent 04480ca commit 14ed83e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 26 deletions.
37 changes: 12 additions & 25 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# 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...
# 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

Expand All @@ -16,6 +15,8 @@ on:
jobs:
setup:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -26,20 +27,13 @@ jobs:
run: |
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)
if [ -z "$app_list" ]; then
app_list_json='[]'
else
app_list_json=$(echo $app_list | jq -R -s -c 'split(" ")')
fi
app_list=$(echo "$changed_files" | grep -E 'docker/.*/(Dockerfile)' | awk -F'/' '{print $2}' | sort | uniq)
app_list_json=$(echo $app_list | jq -R -s -c 'split(" ")')
echo "::set-output name=matrix::{\"app\": $app_list_json}"
build:
needs: setup
runs-on: ubuntu-latest
env:
# You can set it to choice where download from
MEDIA_FROM: "source"
strategy:
matrix: ${{fromJson(needs.setup.outputs.matrix)}}
steps:
Expand Down Expand Up @@ -75,36 +69,29 @@ jobs:
echo "DIRECTORY=docker/$APP" >> $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
if: env.APP == 'apphub' && env.MEDIA_FROM == 'source'
uses: mathze/[email protected]
id: startAndWaitWorkflow
with:
workflow-name: media.yml
token: ${{github.token}}
run-id: dummy
wait-interval: PT10S
if: env.APP == 'apphub'

- name: Wait for Workflow
if: env.APP == 'apphub' && env.MEDIA_FROM == 'source'
- name: Reuse workflow run id
run: "echo ${{ steps.startAndWaitWorkflow.outputs.run-id }}"

- name: Download media.zip from action artifact
if: env.APP == 'apphub'

- name: Download media.zip from artifacts
uses: Legit-Labs/action-download-artifact@v2
if: env.APP == 'apphub' && env.MEDIA_FROM == 'source'
with:
workflow: media.yml
name: media
path: ${{env.DIRECTORY}}

- name: Download media-latest.zip from Websoft9 artifact
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 ---------------------#
if: env.APP == 'apphub'
##------------ special task for apphub end----------------------#

- name: Build & push Docker image
uses: mr-smithers-excellent/docker-build-push@v6
Expand Down
2 changes: 1 addition & 1 deletion docker/apphub/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 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
Expand Down

0 comments on commit 14ed83e

Please sign in to comment.