ci: docker: Combine test and build+publish workflows

This commit is contained in:
Richard Hansen 2022-01-27 17:33:33 -05:00
parent a6fcc92d2a
commit e80e1c0221
2 changed files with 27 additions and 28 deletions

View File

@ -1,10 +1,13 @@
name: Docker
on:
pull_request:
push:
branches:
- 'develop'
tags:
- 'v?[0-9]+.[0-9]+.[0-9]+'
env:
TEST_TAG: etherpad/etherpad:test
jobs:
docker:
runs-on: ubuntu-latest
@ -15,8 +18,29 @@ jobs:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build and export to Docker
uses: docker/build-push-action@v2
with:
context: .
load: true
tags: ${{ env.TEST_TAG }}
-
name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
-
name: Test
run: |
docker run --rm -d -p 9001:9001 ${{ env.TEST_TAG }}
./src/bin/installDeps.sh
sleep 3
(cd src && npm run test-container)
git clean -dxf .
-
name: Docker meta
if: github.event_name == 'push'
id: meta
uses: docker/metadata-action@v3
with:
@ -28,16 +52,17 @@ jobs:
type=semver,pattern={{major}}
-
name: Log in to Docker Hub
if: github.event_name != 'pull_request'
if: github.event_name == 'push'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
if: github.event_name == 'push'
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@ -1,26 +0,0 @@
name: "Dockerfile"
# any branch is useful for testing before a PR is submitted
on: [push, pull_request]
jobs:
dockerfile:
# run on pushes to any branch
# run on PRs from external forks
if: |
(github.event_name != 'pull_request')
|| (github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id)
name: build image and run connectivity test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: docker build
run: |
docker build -t etherpad:test .
docker run -d -p 9001:9001 etherpad:test
./src/bin/installDeps.sh
sleep 3 # delay for startup?
cd src && npm run test-container