Fix workflow #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image CI | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
services: | |
docker: | |
image: docker:19.03.12 | |
options: --privileged | |
steps: | |
# Checkout code | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Run Docker Compose | |
- name: Set up Docker Compose | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y python3-pip | |
pip3 install docker-compose | |
docker-compose -f ./test/docker-compose.yml up --build --abort-on-container-exit | |
# Check test results | |
- name: Check test results | |
run: | | |
docker-compose -f ./test/docker-compose.yml down | |
if [ $(docker-compose ps -q test-runner | xargs docker inspect -f '{{.State.ExitCode}}') -ne 0 ]; then | |
echo "Tests failed!" | |
exit 1 | |
else | |
echo "Tests passed!" | |
fi | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: linux/arm64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and push Docker image | |
run: | | |
docker buildx build \ | |
--platform linux/arm64,linux/amd64 \ | |
--file Dockerfile \ | |
--tag ghcr.io/n3cr0s1s/necroginx:latest \ | |
--push . |