Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirroring fix #4168

Merged
merged 3 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/deploy-ALPHA-flavors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
# Set the agent to run on
runs-on: ${{ matrix.os }}
permissions:
actions: write
packages: write
strategy:
fail-fast: false
Expand Down Expand Up @@ -121,7 +122,6 @@ jobs:
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" }'
ref: ${{ github.ref_name }}

- name: Build Worker Image
uses: docker/build-push-action@v6
Expand All @@ -145,8 +145,7 @@ jobs:
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" }'
ref: ${{ github.ref_name }}
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
29 changes: 17 additions & 12 deletions .github/workflows/deploy-ALPHA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
# Set the agent to run on
runs-on: ubuntu-latest
permissions:
actions: write
packages: write
# Only run this on the main repo
if: github.repository == 'oxsecurity/megalinter' && !contains(github.event.head_commit.message, 'skip deploy')
Expand Down Expand Up @@ -106,6 +107,12 @@ 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 @@ -124,6 +131,12 @@ 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 @@ -142,16 +155,8 @@ jobs:
tags: |
ghcr.io/oxsecurity/megalinter-worker:alpha

- 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
- name: Pull image from GHCR
run: docker system prune -a --volumes --force && docker system prune -a --volumes --force && docker pull ghcr.io/oxsecurity/megalinter:alpha
- name: Tag image for Docker Hub
run: docker tag ghcr.io/oxsecurity/megalinter:alpha oxsecurity/megalinter:alpha
- name: Push image to Docker Hub
run: docker push oxsecurity/megalinter:alpha
workflow: mirror-docker-image.yml
inputs: '{ "source-image": "ghcr.io/oxsecurity/megalinter-worker:alpha", "target-image": "docker.io/oxsecurity/megalinter-worker:alpha" }'
31 changes: 30 additions & 1 deletion .github/workflows/mirror-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,36 @@ on:
default: 'true'

jobs:
copy-to-docker-hub:

copy-to-docker-hub-alpha:
if: github.ref_name == 'alpha'
runs-on: ubuntu-latest
environment:
name: alpha
steps:
# Free disk space
- name: Free Disk space
if: github.event.inputs.free-space-before == 'true'
shell: bash
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
# Login to docker hub
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Copy ghrc.io image to Docker Hub
- name: Pull image from GHCR
run: docker pull "${{ github.event.inputs.source-image }}"
- name: Tag image for Docker Hub
run: docker tag "${{ github.event.inputs.source-image }}" "${{ github.event.inputs.target-image }}"
- name: Push image to Docker Hub
run: docker push "${{ github.event.inputs.target-image }}"

copy-to-docker-hub-main:
if: github.ref_name == 'main'
runs-on: ubuntu-latest
environment:
name: beta
Expand Down
Loading