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

fix docker ci #47

Merged
merged 1 commit into from
Jun 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 16 additions & 11 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ jobs:
build:
runs-on: ubuntu-latest
outputs:
wikmd_tag: ${{ steps.meta.outputs.tags }}
wikmd_tags: ${{ steps.meta.outputs.tags }}
json: ${{ steps.meta.outputs.json }}
strategy:
matrix:
architecture:
Expand All @@ -28,16 +29,14 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: |
linbreux/wikmd
images: linbreux/wikmd
tags: |
type=ref,event=pr
type=ref,event=tag
type=edge,branch=$repo.default_branch
type=edge

- name: Check docker image tag
run: |
echo "Creating Docker image ${{ steps.meta.outputs.tags }}"
run: echo "Creating Docker image ${{ steps.meta.outputs.tags }}"

- name: Build & export
uses: docker/build-push-action@v3
Expand All @@ -56,6 +55,11 @@ jobs:
test:
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
tag: ${{ fromJSON(needs.build.outputs.json).tags }}
name: "test-${{ matrix.tag }}"
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -71,29 +75,30 @@ jobs:
docker load --input /tmp/wikmd.tar
docker image ls -a

# Start a default Wikmd container
# Start a default wikmd container
- name: Start wikmd
run: docker run -d --name wikmd -p 5000:5000 ${{ needs.build.outputs.wikmd_tag }}
run: docker run -d --name wikmd -p 5000:5000 ${{ matrix.tag }}

# Wait for wikmd to be up and running
- name: Sleep
uses: jakejarvis/wait-action@master
with:
time: '20s'

# Print some debugging
- name: Check running containers
run: docker ps -a

- name: Check docker logs
run: docker logs wikmd

# Check that Wikmd is up and running
# Check that wikmd is up and running
- name: Assert wikmd status
run: curl -I localhost:5000 2>&1 | awk '/HTTP\// {print $2}' | grep -w "200\|301"

publish:
# Publish if official repo and push to 'main' or new tag
if: |
true &&
github.repository == 'Linbreux/wikmd' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-latest
Expand All @@ -113,4 +118,4 @@ jobs:
with:
file: docker/Dockerfile
push: true
tags: ${{ needs.build.outputs.wikmd_tag }}
tags: ${{ needs.build.outputs.wikmd_tags }}