Skip to content

Commit

Permalink
Merge pull request #274 from Z1Turn0/main
Browse files Browse the repository at this point in the history
support workflow_call publish docker
  • Loading branch information
geihob authored Feb 3, 2024
2 parents 5de67e6 + 51478c4 commit 644e5fe
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 26 deletions.
36 changes: 17 additions & 19 deletions .github/workflows/check-loser-homework.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Check loser homework

on:
workflow_call:
inputs:
docker_namespaces:
required: true
type: string
workflow_dispatch:
push:
branches: [ "main" ]
Expand All @@ -20,10 +25,12 @@ on:
- 'src/群友提交/**'

jobs:
whether-to-build-all:
prepare:
runs-on: ubuntu-latest
outputs:
need_build_all: ${{ steps.changed-files.outputs.any_changed }}
need_build_all: ${{ steps.changed-files.outputs.any_changed ||
( github.event_name != 'pull_request' && github.event_name != 'push' ) }}
docker_namespaces: ${{ inputs.docker_namespaces == '' && 'mq-b/loser-homework' || inputs.docker_namespaces}}

steps:
- uses: actions/checkout@v4
Expand All @@ -42,18 +49,12 @@ jobs:
src/群友提交/**/input.txt
src/群友提交/**/output.txt
convert-repo-to-lowercase:
runs-on: ubuntu-latest
outputs:
repo_lowercase: ${{ steps.github-repo-lowercase.outputs.REPO_LC }}
steps:
- name: Convert GITHUB_REPOSITORY lowercase
id: github-repo-lowercase
run: |
echo "REPO_LC=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT
check:
needs: [ whether-to-build-all, convert-repo-to-lowercase ]
needs: prepare
env:
PYTHONIOENCODING: "utf-8"
DOTNET_CLI_FORCE_UTF8_ENCODING: "true"

strategy:
matrix:
include:
Expand All @@ -69,7 +70,7 @@ jobs:
cxx_compiler: clang++-17
c_compiler: clang-17
cxx_flags: -stdlib=libc++
container: ghcr.io/${{ needs.convert-repo-to-lowercase.outputs.repo_lowercase }}/clang17
container: ghcr.io/${{ needs.prepare.outputs.docker_namespaces }}/clang17
shell: bash
use-ninja: true

Expand All @@ -86,15 +87,12 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}

env:
PYTHONIOENCODING: "utf-8"
DOTNET_CLI_FORCE_UTF8_ENCODING: "true"

steps:
- uses: actions/checkout@v4

- name: delete unchanged cpp files
if: needs.whether-to-build-all.outputs.need_build_all == 'false'
if: |
needs.prepare.outputs.need_build_all == 'false'
uses: ./.github/actions/delete-unchanged-cpp-files
with:
path: src/群友提交
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: Publish Docker

on:
create:
workflow_call:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- '.github/workflows/publish-docker.yml'
- '.github/docker/**'
# pull_request:
# branches: [ "main" ]
# paths:
# - '.github/workflows/publish-docker.yml'
# - '.github/docker/**'
pull_request:
branches: [ "main" ]
paths:
- '.github/workflows/publish-docker.yml'
- '.github/docker/**'


jobs:
Expand All @@ -34,4 +34,5 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
dockerfile: ${{ matrix.dockerfile }}
tags: "latest"
tags: "latest"
no_push: ${{ github.event_name == 'pull_request' }}
30 changes: 30 additions & 0 deletions .github/workflows/test-your-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test your docker package

on:
workflow_dispatch:
inputs:
publish_docker:
type: boolean
default: true
description: publish your docker

jobs:
convert-repo-to-lowercase:
runs-on: ubuntu-latest
outputs:
repo_lowercase: ${{ steps.github-repo-lowercase.outputs.REPO_LC }}
steps:
- name: Convert GITHUB_REPOSITORY lowercase
id: github-repo-lowercase
run: |
echo "REPO_LC=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT
publish-docker:
if: inputs.publish_docker
uses: ./.github/workflows/publish-docker.yml

check-loser-homework:
needs: [convert-repo-to-lowercase, publish-docker]
uses: ./.github/workflows/check-loser-homework.yml
with:
docker_namespaces: ${{ needs.convert-repo-to-lowercase.outputs.repo_lowercase }}

0 comments on commit 644e5fe

Please sign in to comment.