Skip to content

Commit

Permalink
Mirroring fix (#4168)
Browse files Browse the repository at this point in the history
* Alpha big image

* permissions

* Handle permissions
  • Loading branch information
nvuillam authored Oct 20, 2024
1 parent 19bba71 commit af6d8d1
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 16 deletions.
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

0 comments on commit af6d8d1

Please sign in to comment.