diff --git a/.github/workflows/bot_run_tests.yml b/.github/workflows/bot_run_tests.yml new file mode 100644 index 0000000..c0b5cf0 --- /dev/null +++ b/.github/workflows/bot_run_tests.yml @@ -0,0 +1,22 @@ +name: Run tests on PR +on: issue_comment + +jobs: + pr_commented: + name: Run Tests for PR + if: > + github.event.issue.pull_request && + contains(github.event.issue.bodyText, '/run tests') + runs-on: ubuntu-latest + steps: + - name: Check association + run: | + allowed=("OWNER" "COLLABORATOR") + value="\<${{ github.event.issue.author_association }}\>" + + if [[ ${array[@]} =~ $value ]] + then + exit 0 + else + exit 1 + fi diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e02df61..fa5c18e 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -6,7 +6,12 @@ on: - 'main' tags: - 'v*' - pull_request: + + workflow_run: + workflows: [Run Tests on PR] + types: + - completed + concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -26,6 +31,10 @@ env: jobs: build-container: + if: > + github.event_name == 'push' || + ( github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' ) name: Build Container Image runs-on: ubuntu-latest permissions: @@ -39,9 +48,8 @@ jobs: fetch-depth: 0 fetch-tags: 'true' - - name: Docker meta for GHCR - if: github.event_name != 'pull_request' - id: meta_ghcr + - name: Docker meta + id: meta uses: docker/metadata-action@v5 with: images: | @@ -52,29 +60,15 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - - name: Docker meta for Docker Hub - if: github.event_name == 'pull_request' - id: meta_docker - uses: docker/metadata-action@v5 - with: - images: | - docker.io/${{ github.repository }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - - name: Buildah Build id: build-image uses: redhat-actions/buildah-build@v2 with: containerfiles: Containerfile - tags: ${{ steps.meta_ghcr.outputs.tags || steps.meta_docker.outputs.tags }} - labels: ${{ steps.meta_ghcr.outputs.labels || steps.meta_docker.outputs.labels }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} - - name: Push image to GHCR - if: github.event_name != 'pull_request' + - name: Push image uses: redhat-actions/push-to-registry@v2 with: image: ${{ steps.build-image.outputs.image }} @@ -82,15 +76,6 @@ jobs: username: ${{ github.actor }} password: ${{ github.token }} - - name: Push image to Docker - if: github.event_name == 'pull_request' - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ steps.build-image.outputs.image }} - tags: ${{ steps.build-image.outputs.tags }} - username: ${{ secrets.DOCKER_LOGIN }} - password: ${{ secrets.DOCKER_TOKEN }} - build-and-push-iso: name: Build ISO runs-on: ubuntu-latest