Skip to content

Commit

Permalink
Apply docker mirroring to all workflows (#4169)
Browse files Browse the repository at this point in the history
* Apply to all workflows

* Do not deploy on docker hub for alpha
  • Loading branch information
nvuillam authored Oct 20, 2024
1 parent af6d8d1 commit 663f4a7
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 171 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/deploy-ALPHA-flavors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@ jobs:
tags: |
ghcr.io/oxsecurity/megalinter-${{ matrix.flavor }}:alpha
- name: Invoke Mirror docker image workflow (Flavor image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-${{ matrix.flavor }}:alpha", "target-image": "docker.io/oxsecurity/megalinter-${{ matrix.flavor }}:alpha" }'

- name: Build Worker Image
uses: docker/build-push-action@v6
with:
Expand All @@ -141,12 +135,6 @@ jobs:
tags: |
ghcr.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:alpha
- name: Invoke Mirror docker image workflow (Flavor worker image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:alpha", "target-image": "docker.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:alpha" }'

##############################################
# Check Docker image security with Trivy #
##############################################
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/deploy-ALPHA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@ jobs:
ghcr.io/oxsecurity/megalinter-server:alpha
# ghcr.io/oxsecurity/megalinter-server:alpha-${{ github.sha }}

- name: Invoke Mirror docker image workflow (Server image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-server:alpha", "target-image": "docker.io/oxsecurity/megalinter-server:alpha" }'

- name: Build & Push Docker Image
uses: docker/build-push-action@v6
with:
Expand All @@ -131,12 +125,6 @@ jobs:
ghcr.io/oxsecurity/megalinter:alpha
# ghcr.io/oxsecurity/megalinter:alpha-${{ github.sha }}

- name: Invoke Mirror docker image workflow (MegaLinter image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter:alpha", "target-image": "docker.io/oxsecurity/megalinter:alpha" }'

- name: Build & Push Worker Docker Image
uses: docker/build-push-action@v6
with:
Expand All @@ -154,9 +142,3 @@ jobs:
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
tags: |
ghcr.io/oxsecurity/megalinter-worker:alpha
- name: Invoke Mirror docker image workflow (Worker image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-worker:alpha", "target-image": "docker.io/oxsecurity/megalinter-worker:alpha" }'
32 changes: 10 additions & 22 deletions .github/workflows/deploy-BETA-flavors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ jobs:
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
tags: ${{ steps.meta.outputs.tags }}

- name: Invoke Mirror docker image workflow (Main image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "${{ steps.meta.outputs.tags }}", "target-image": "${{ steps.meta-dhub.outputs.tags }}" }'

- name: Build Worker Image
uses: docker/build-push-action@v6
with:
Expand All @@ -192,29 +198,11 @@ jobs:
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
tags: ${{ steps.meta-w.outputs.tags }}

- name: Login to Docker Hub
uses: docker/login-action@v3
- name: Invoke Mirror docker image workflow (Main image)
uses: benc-uk/workflow-dispatch@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Copy ghrc.io image to Docker Hub (main image)
- name: Debug output
run: "echo \"Tag steps.meta.outputs.tags: ${{ steps.meta.outputs.tags }}\""
- name: Pull image from GHCR
run: docker system prune -a --volumes --force && docker pull "${{ steps.meta.outputs.tags }}"
- name: Tag image for Docker Hub
run: docker tag "${{ steps.meta.outputs.tags }}" "${{ steps.meta-dhub.outputs.tags }}"
- name: Push image to Docker Hub
run: docker push "${{ steps.meta-dhub.outputs.tags }}"

# Copy ghrc.io image to Docker Hub (worker)
- name: Pull image from GHCR
run: docker system prune -a --volumes --force && docker pull "${{ steps.meta-w.outputs.tags }}"
- name: Tag image for Docker Hub
run: docker tag "${{ steps.meta-w.outputs.tags }}" "${{ steps.meta-w-dhub.outputs.tags }}"
- name: Push image to Docker Hub
run: docker push "${{ steps.meta-w-dhub.outputs.tags }}"
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "${{ steps.meta-w.outputs.tags }}", "target-image": "${{ steps.meta-w-dhub.outputs.tags }}" }'

##############################################
# Check Docker image security with Trivy #
Expand Down
18 changes: 4 additions & 14 deletions .github/workflows/deploy-BETA-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,21 +262,11 @@ jobs:
docker run -e TEST_CASE_RUN=true -e OUTPUT_FORMAT=text -e OUTPUT_FOLDER=${{ github.sha }} -e OUTPUT_DETAIL=detailed -e GITHUB_SHA=${{ github.sha }} -e GITHUB_REPOSITORY=${GITHUB_REPOSITORY} -e GITHUB_BRANCH=${GITHUB_BRANCH} -e GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" -e TEST_KEYWORDS="${TEST_KEYWORDS_TO_USE}" -e MEGALINTER_VOLUME_ROOT="${GITHUB_WORKSPACE}" -v "/var/run/docker.sock:/var/run/docker.sock:rw" -v ${GITHUB_WORKSPACE}:/tmp/lint ${{ fromJson(steps.meta.outputs.json).tags[0]}}
timeout-minutes: 30

- name: Login to Docker Hub
uses: docker/login-action@v3
- name: Invoke Mirror docker image workflow (Standalone linter image)
uses: benc-uk/workflow-dispatch@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Copy ghrc.io image to Docker Hub (main image)
- name: Debug output
run: "echo \"Tag steps.meta.outputs.tags: ${{ fromJson(steps.meta-dhub.outputs.json).tags[0]}}\""
- name: Pull image from GHCR
run: docker system prune -a --volumes --force && docker pull "${{ fromJson(steps.meta.outputs.json).tags[0]}}"
- name: Tag image for Docker Hub
run: docker tag "${{ fromJson(steps.meta.outputs.json).tags[0]}}" "${{ fromJson(steps.meta-dhub.outputs.json).tags[0]}}"
- name: Push image to Docker Hub
run: docker push "${{ fromJson(steps.meta-dhub.outputs.json).tags[0]}}"
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "${{ fromJson(steps.meta.outputs.json).tags[0]}}", "target-image": "${{ fromJson(steps.meta-dhub.outputs.json).tags[0]}}" }'

##############################################
# Check Docker image security with Trivy #
Expand Down
44 changes: 16 additions & 28 deletions .github/workflows/deploy-BETA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ jobs:
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
tags: ${{ steps.meta-s.outputs.tags }}

- name: Invoke Mirror docker image workflow (Server image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "${{ steps.meta-s.outputs.tags }}", "target-image": "${{ steps.meta-s-dhub.outputs.tags }}" }'

- name: Build & Push Docker Image
uses: docker/build-push-action@v6
with:
Expand All @@ -178,6 +184,12 @@ jobs:
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
tags: ${{ steps.meta.outputs.tags }}

- name: Invoke Mirror docker image workflow (Main image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "${{ steps.meta.outputs.tags }}", "target-image": "${{ steps.meta-dhub.outputs.tags }}" }'

- name: Build & Push Docker Worker Image
uses: docker/build-push-action@v6
with:
Expand All @@ -195,35 +207,11 @@ jobs:
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
tags: ${{ steps.meta-w.outputs.tags }}

- name: Login to Docker Hub
uses: docker/login-action@v3
- name: Invoke Mirror docker image workflow (Worker image)
uses: benc-uk/workflow-dispatch@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Copy ghrc.io image to Docker Hub (main image)
- name: Pull image from GHCR
run: docker system prune -a --volumes --force && docker pull "${{ steps.meta.outputs.tags }}"
- name: Tag image for Docker Hub
run: docker tag "${{ steps.meta.outputs.tags }}" "${{ steps.meta-dhub.outputs.tags }}"
- name: Push image to Docker Hub
run: docker push "${{ steps.meta-dhub.outputs.tags }}"

# Copy ghrc.io image to Docker Hub (server)
- name: Pull image from GHCR
run: docker system prune -a --volumes --force && docker pull "${{ steps.meta-s.outputs.tags }}"
- name: Tag image for Docker Hub
run: docker tag "${{ steps.meta-s.outputs.tags }}" "${{ steps.meta-s-dhub.outputs.tags }}"
- name: Push image to Docker Hub
run: docker push "${{ steps.meta-s-dhub.outputs.tags }}"

# Copy ghrc.io image to Docker Hub (worker)
- name: Pull image from GHCR
run: docker system prune -a --volumes --force && docker pull "${{ steps.meta-w.outputs.tags }}"
- name: Tag image for Docker Hub
run: docker tag "${{ steps.meta-w.outputs.tags }}" "${{ steps.meta-w-dhub.outputs.tags }}"
- name: Push image to Docker Hub
run: docker push "${{ steps.meta-w-dhub.outputs.tags }}"
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "${{ steps.meta-w.outputs.tags }}", "target-image": "${{ steps.meta-w-dhub.outputs.tags }}" }'

# ###############################
# # Run tests for code coverage #
Expand Down
71 changes: 30 additions & 41 deletions .github/workflows/deploy-RELEASE-flavors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ jobs:
ghcr.io/oxsecurity/megalinter-${{ matrix.flavor }}:${{ github.event.release.tag_name }}
ghcr.io/oxsecurity/megalinter-${{ matrix.flavor }}:latest
- name: Invoke Mirror docker image workflow (Main image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-${{ matrix.flavor }}:v8", "target-image": "docker.io/oxsecurity/megalinter-${{ matrix.flavor }}:v8" }'
- name: Invoke Mirror docker image workflow (Main image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-${{ matrix.flavor }}:v8", "target-image": "docker.io/oxsecurity/megalinter-${{ matrix.flavor }}:${{ github.event.release.tag_name }}" }'
- name: Invoke Mirror docker image workflow (Main image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-${{ matrix.flavor }}:v8", "target-image": "docker.io/oxsecurity/megalinter-${{ matrix.flavor }}:latest" }'

- name: Build Worker Image
uses: docker/build-push-action@v6
with:
Expand All @@ -126,49 +142,22 @@ jobs:
ghcr.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:${{ github.event.release.tag_name }}
ghcr.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:latest
- name: Login to Docker Hub
uses: docker/login-action@v3
- name: Invoke Mirror docker image workflow (Main image)
uses: benc-uk/workflow-dispatch@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Copy ghrc.io image to Docker Hub (main image)
- name: Pull image from GHCR
run: docker system prune -a --volumes --force && docker pull ghcr.io/oxsecurity/megalinter-${{ matrix.flavor }}:v8

- name: Tag image for Docker Hub
run: docker tag ghcr.io/oxsecurity/megalinter-${{ matrix.flavor }}:v8 docker.io/oxsecurity/megalinter-${{ matrix.flavor }}:v8
- name: Push image to Docker Hub v8
run: docker push docker.io/oxsecurity/megalinter-${{ matrix.flavor }}:v8

- name: Tag image for Docker Hub
run: docker tag ghcr.io/oxsecurity/megalinter-${{ matrix.flavor }}:v8 docker.io/oxsecurity/megalinter-${{ matrix.flavor }}:${{ github.event.release.tag_name }}
- name: Push image to Docker Hub ${{ github.event.release.tag_name }}
run: docker push docker.io/oxsecurity/megalinter-${{ matrix.flavor }}:${{ github.event.release.tag_name }}

- name: Tag image for Docker Hub
run: docker tag ghcr.io/oxsecurity/megalinter-${{ matrix.flavor }}:v8 docker.io/oxsecurity/megalinter-${{ matrix.flavor }}:latest
- name: Push image to Docker Hub latest
run: docker push docker.io/oxsecurity/megalinter-${{ matrix.flavor }}:latest

# Copy ghrc.io image to Docker Hub (worker)
- name: Pull image from GHCR
run: docker system prune -a --volumes --force && docker pull ghcr.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:v8

- name: Tag image for Docker Hub
run: docker tag ghcr.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:v8 docker.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:v8
- name: Push image to Docker Hub v8
run: docker push docker.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:v8

- name: Tag image for Docker Hub
run: docker tag ghcr.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:v8 docker.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:${{ github.event.release.tag_name }}
- name: Push image to Docker Hub ${{ github.event.release.tag_name }}
run: docker push docker.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:${{ github.event.release.tag_name }}
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:v8", "target-image": "docker.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:v8" }'
- name: Invoke Mirror docker image workflow (Main image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:v8", "target-image": "docker.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:${{ github.event.release.tag_name }}" }'
- name: Invoke Mirror docker image workflow (Main image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:v8", "target-image": "docker.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:latest" }'

- name: Tag image for Docker Hub
run: docker tag ghcr.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:v8 docker.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:latest
- name: Push image to Docker Hub latest
run: docker push docker.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:latest

##############################################
# Check Docker image security with Trivy #
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/deploy-RELEASE-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,22 @@ jobs:
ghcr.io/oxsecurity/megalinter-only-${{ matrix.linter }}:${{ github.event.release.tag_name }}
ghcr.io/oxsecurity/megalinter-only-${{ matrix.linter }}:latest
- name: Invoke Mirror docker image workflow (Standalone image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-only-${{ matrix.linter }}:v8", "target-image": "docker.io/oxsecurity/megalinter-only-${{ matrix.linter }}:v8" }'
- name: Invoke Mirror docker image workflow (Standalone image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-only-${{ matrix.linter }}:v8", "target-image": "docker.io/oxsecurity/megalinter-only-${{ matrix.linter }}:${{ github.event.release.tag_name }}" }'
- name: Invoke Mirror docker image workflow (Standalone image)
uses: benc-uk/workflow-dispatch@v1
with:
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-only-${{ matrix.linter }}:v8", "target-image": "docker.io/oxsecurity/megalinter-only-${{ matrix.linter }}:latest" }'

#####################################
# Run Linter test cases #
#####################################
Expand Down
Loading

0 comments on commit 663f4a7

Please sign in to comment.