Skip to content

Commit

Permalink
Update docker-hub-platform.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga authored Dec 18, 2024
1 parent da7487f commit c794cc9
Showing 1 changed file with 25 additions and 45 deletions.
70 changes: 25 additions & 45 deletions .github/workflows/docker-hub-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,35 @@ jobs:
run: |
./docker-compose.sh platform
- name: Push Platform Images
- name: Tag Platform Images
run: |
platform_tag=$(echo "${{ matrix.platform }}" | tr '/' '-')
echo "Platform Tag: ${platform_tag}"
for tag in "deps" "dev" "runtime" "cli"; do
echo "Pushing image for tag: ${tag} with platform: ${platform_tag}"
docker tag ${DOCKER_USERNAME}/${IMAGE_NAME}:${tag} \
${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:${tag}-${platform_tag}
done
- name: Create Test Dockerfile
run: |
cat <<EOF > Dockerfile
FROM ${DOCKER_USERNAME}/${IMAGE_NAME}:cli
RUN echo "console.log('abcde')" > script.js
RUN metacallcli script.js
EOF
- name: Build and Test Image
run: |
set -exuo pipefail
platform_tag=$(echo "${{ matrix.platform }}" | tr '/' '-')
docker build --platform ${{ matrix.platform }} -t test-image .
docker run --rm --platform=${{ matrix.platform }} test-image | grep "abcde"
- name: Push Platform Images
run: |
platform_tag=$(echo "${{ matrix.platform }}" | tr '/' '-')
for tag in "deps" "dev" "runtime" "cli"; do
echo "Pushing image for tag: ${tag} with platform: ${platform_tag}"
docker push ${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:${tag}-${platform_tag}
done
Expand Down Expand Up @@ -100,7 +121,7 @@ jobs:
docker manifest push ${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:${tag}
done
- name: Create Version-Specific Tags
- name: Create Version Specific Tags
if: startsWith(github.ref, 'refs/tags/')
run: |
VERSION=${GITHUB_REF#refs/tags/v}
Expand All @@ -123,50 +144,9 @@ jobs:
docker manifest create ${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:latest ${cli_platform_tags} --amend
docker manifest push ${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:latest
test:
name: Test CLI Image
needs: manifest
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
- linux/riscv64
- linux/ppc64le
- linux/s390x
- linux/386
- linux/arm/v7
- linux/arm/v6
# - linux/mips64le
# - linux/mips64

steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Create Test Dockerfile
run: |
cat <<EOF > Dockerfile
FROM ${DOCKER_USERNAME}/${IMAGE_NAME}:cli
RUN echo "console.log('abcde')" > script.js
RUN metacallcli script.js
EOF
- name: Build and Test Image
run: |
platform_tag=$(echo "${{ matrix.platform }}" | tr '/' '-')
docker pull ${DOCKER_USERNAME}/${IMAGE_NAME}:cli
docker build --platform ${{ matrix.platform }} -t test-image .
docker run --rm --platform=${{ matrix.platform }} test-image
cleanup:
name: Cleanup Platform Specific Tags
needs: [build, manifest, test]
needs: [build, manifest]
runs-on: ubuntu-latest
if: always()
steps:
Expand Down

0 comments on commit c794cc9

Please sign in to comment.