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

Move from Travis to GHA #22

Merged
merged 1 commit into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/workflows/test_buildx_and_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Test and publish

on: [push, pull_request]

env:
REPOSITORY: moodle-exttests
DOCKERHUB_OWNER: moodlehq
GH_OWNER: moodlehq

jobs:
Test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Build image
run: |
docker build . -t moodle-exttests

- name: Run tests
run: |
docker run --name test0 -d -p 8000:80 moodle-exttests
until [ "`docker inspect -f {{.State.Health.Status}} test0`" == "healthy" ]; do
sleep 0.5;
done;
curl --fail -L http://127.0.0.1:8000/test_redir.php

- name: Display container logs on failure
if: failure()
run: |
docker logs test0

- name: Cleanup docker images
run: |
docker rm -f test0

Publish:
# Completely avoid forks and pull requests to try this job.
if: github.repository_owner == 'moodlehq' && github.event_name == 'push'
# Requires Test to pass
needs: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

# Calculate the tags to be pussed to the registries.
- name: Calculate image tag names
id: calculatetags
uses: docker/metadata-action@v3
with:
images: |
${{ env.DOCKERHUB_OWNER }}/${{ env.REPOSITORY }}
ghcr.io/${{ env.GH_OWNER }}/${{ env.REPOSITORY }}
tags: |
type=raw,value=latest

# https://github.com/docker/setup-qemu-action#usage
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

# https://github.com/marketplace/actions/docker-setup-buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# https://github.com/docker/login-action#docker-hub
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# https://github.com/docker/login-action#github-container-registry
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}

# https://github.com/docker/build-push-action#multi-platform-image
- name: Build and push to Docker Hub and Github registries
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.calculatetags.outputs.tags }}

# https://github.com/peter-evans/dockerhub-description
# It's horrible that we need to use password here instead of PAT, because
# that's only available via CLI what defeats 2FA. Anyway, we need to
# auto-update the description, so using it (till available via PAT).
# Link: https://github.com/peter-evans/dockerhub-description/issues/10
# Note that we only update the description with the master branch version.
- name: Set Docker Hub description from README.md
if: github.ref == 'refs/heads/master'
uses: peter-evans/dockerhub-description@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: ${{ env.DOCKERHUB_OWNER }}/${{ env.REPOSITORY }}
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Test files for external Moodle tests
====================================

[![Build Status](https://travis-ci.com/moodlehq/moodle-exttests.svg?branch=master)](https://travis-ci.com/moodlehq/moodle-exttests/branches)
[![Test and publish](https://github.com/moodlehq/moodle-exttests/actions/workflows/test_buildx_and_publish.yml/badge.svg?branch=master)](https://github.com/moodlehq/moodle-php-apache/actions/workflows/test_buildx_and_publish.yml)

**It's really important to keep these files completely unmodified in order to obtain coherent test results in all supported Moodle versions.**

Expand Down