2021-11-30 02:02:41 +00:00
|
|
|
name: Docker
|
|
|
|
on:
|
2022-01-27 22:33:33 +00:00
|
|
|
pull_request:
|
2021-11-30 02:02:41 +00:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- 'develop'
|
|
|
|
tags:
|
|
|
|
- 'v?[0-9]+.[0-9]+.[0-9]+'
|
2022-01-27 22:33:33 +00:00
|
|
|
env:
|
|
|
|
TEST_TAG: etherpad/etherpad:test
|
2022-04-26 01:08:54 +00:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2021-11-30 02:02:41 +00:00
|
|
|
jobs:
|
|
|
|
docker:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-01-27 22:43:05 +00:00
|
|
|
-
|
|
|
|
name: Check out
|
2023-09-04 16:51:22 +00:00
|
|
|
uses: actions/checkout@v4
|
2022-03-19 20:57:29 +00:00
|
|
|
-
|
|
|
|
name: Set up QEMU
|
|
|
|
if: github.event_name == 'push'
|
2023-09-13 17:52:50 +00:00
|
|
|
uses: docker/setup-qemu-action@v3
|
2022-01-27 22:44:06 +00:00
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
2023-09-13 18:03:42 +00:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2022-01-27 22:33:33 +00:00
|
|
|
-
|
|
|
|
name: Build and export to Docker
|
2023-09-13 17:53:42 +00:00
|
|
|
uses: docker/build-push-action@v5
|
2022-01-27 22:33:33 +00:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
load: true
|
|
|
|
tags: ${{ env.TEST_TAG }}
|
2022-01-27 22:47:28 +00:00
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
2022-01-27 22:33:33 +00:00
|
|
|
-
|
|
|
|
name: Set up Node.js
|
2022-02-25 15:32:24 +00:00
|
|
|
uses: actions/setup-node@v3
|
2022-01-27 22:33:33 +00:00
|
|
|
with:
|
|
|
|
node-version: 'lts/*'
|
2022-01-27 22:47:28 +00:00
|
|
|
cache: 'npm'
|
|
|
|
cache-dependency-path: |
|
|
|
|
src/package-lock.json
|
|
|
|
src/bin/doc/package-lock.json
|
2022-01-27 22:33:33 +00:00
|
|
|
-
|
|
|
|
name: Test
|
|
|
|
run: |
|
2022-03-12 00:50:57 +00:00
|
|
|
docker run --rm -d -p 9001:9001 --name test ${{ env.TEST_TAG }}
|
2022-03-12 05:17:10 +00:00
|
|
|
docker logs -f test &
|
2022-01-27 22:33:33 +00:00
|
|
|
./src/bin/installDeps.sh
|
2022-03-12 00:50:57 +00:00
|
|
|
while true; do
|
|
|
|
echo "Waiting for Docker container to start..."
|
|
|
|
status=$(docker container inspect -f '{{.State.Health.Status}}' test) || exit 1
|
|
|
|
case ${status} in
|
|
|
|
healthy) break;;
|
|
|
|
starting) sleep 2;;
|
|
|
|
*) printf %s\\n "unexpected status: ${status}" >&2; exit 1;;
|
|
|
|
esac
|
|
|
|
done
|
2022-01-27 22:33:33 +00:00
|
|
|
(cd src && npm run test-container)
|
|
|
|
git clean -dxf .
|
2022-01-27 22:43:05 +00:00
|
|
|
-
|
|
|
|
name: Docker meta
|
2022-01-27 22:33:33 +00:00
|
|
|
if: github.event_name == 'push'
|
2021-11-30 02:02:41 +00:00
|
|
|
id: meta
|
2023-09-13 17:54:17 +00:00
|
|
|
uses: docker/metadata-action@v5
|
2021-11-30 02:02:41 +00:00
|
|
|
with:
|
|
|
|
images: etherpad/etherpad
|
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
type=semver,pattern={{major}}
|
2022-01-27 22:43:05 +00:00
|
|
|
-
|
|
|
|
name: Log in to Docker Hub
|
2022-01-27 22:33:33 +00:00
|
|
|
if: github.event_name == 'push'
|
2023-09-13 17:53:29 +00:00
|
|
|
uses: docker/login-action@v3
|
2021-11-30 02:02:41 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
2022-01-27 22:43:05 +00:00
|
|
|
-
|
|
|
|
name: Build and push
|
2022-01-27 22:33:33 +00:00
|
|
|
if: github.event_name == 'push'
|
2023-09-13 17:53:42 +00:00
|
|
|
uses: docker/build-push-action@v5
|
2021-11-30 02:02:41 +00:00
|
|
|
with:
|
|
|
|
context: .
|
2022-03-19 20:57:29 +00:00
|
|
|
platforms: linux/amd64,linux/arm64
|
2022-01-27 22:33:33 +00:00
|
|
|
push: true
|
2021-11-30 02:02:41 +00:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|