Skip to content

Commit

Permalink
Upgrade docker hub description, code cleanup and fix #37 and fix #39
Browse files Browse the repository at this point in the history
  • Loading branch information
erseco committed Oct 18, 2023
1 parent dd11b37 commit 0e85950
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,49 @@ jobs:
buildx:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the code
- name: Checkout
uses: actions/checkout@v4

# Step 2: Prepare variables for building and tagging the image
- name: Prepare
id: prepare
run: |
DOCKER_IMAGE=erseco/alpine-moodle
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x
VERSION=${GITHUB_REF#refs/*/}
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $GITHUB_REF == refs/tags/* ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
if [[ $VERSION == "master" ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:beta"
fi
echo ::set-output name=platforms::${DOCKER_PLATFORMS}
echo ::set-output name=tags::${TAGS}
# Step 3: Set up QEMU for multi-platform builds
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all

# Step 4: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
id: buildx

# Step 5: Login to DockerHub
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build
run: |
docker buildx build .
- name: Test
run: |
docker-compose version
docker-compose --file docker-compose.test.yml up --exit-code-from sut --timeout 10 --build
# Step 6: Build and Push (if not a PR)
- name: Build and push
uses: docker/build-push-action@v5
with:
Expand All @@ -65,9 +59,22 @@ jobs:
tags: ${{ steps.prepare.outputs.tags }}
platforms: ${{ steps.prepare.outputs.platforms }}

# Step 6.5: Debug Build for PRs
- name: Debug Build on PR
if: github.event_name == 'pull_request'
run: |
docker buildx build --load .
# Step 7: Test the built image
- name: Test
run: |
docker-compose version
docker-compose --file docker-compose.test.yml up --exit-code-from sut --timeout 10 --build
# Step 8: Update Docker Hub Description
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
short-description: ${{ github.event.repository.description }}
short-description: ${{ github.event.repository.description }}

0 comments on commit 0e85950

Please sign in to comment.