Take current scheme (HTTP/S) in to account when redirecting. #11
Workflow file for this run
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: Test and publish | |
on: [push, pull_request, workflow_dispatch] | |
env: | |
REPOSITORY: moodle-exttests | |
DOCKERHUB_OWNER: moodlehq | |
GH_OWNER: moodlehq | |
jobs: | |
Test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- 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' && contains(fromJson('["push", "workflow_dispatch"]'), github.event_name) | |
# Requires Test to pass | |
needs: Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Calculate the tags to be pussed to the registries. | |
- name: Calculate image tag names | |
id: calculatetags | |
uses: docker/metadata-action@v4 | |
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@v2 | |
# https://github.com/marketplace/actions/docker-setup-buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# https://github.com/docker/login-action#docker-hub | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
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@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
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@v3 | |
with: | |
context: . | |
file: Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.calculatetags.outputs.tags }} | |
# https://github.com/peter-evans/dockerhub-description | |
# 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@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
repository: ${{ env.DOCKERHUB_OWNER }}/${{ env.REPOSITORY }} |