Skip to content
Draft
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
25 changes: 25 additions & 0 deletions .github/templates/docker-build-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

jobs:
build-and-push-image:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
run: |
RELEASE_DATE=$(date --rfc-3339=date)
IMAGE_NAME="${{ env.REGISTRY }}/${{ github.actor }}/${{ env.PROJECTNAME }}"

docker build -t $IMAGE_NAME:$RELEASE_DATE -t $IMAGE_NAME:latest ./${{ env.PROJECTNAME}}/
docker push $IMAGE_NAME:$RELEASE_DATE
docker push $IMAGE_NAME:latest

52 changes: 10 additions & 42 deletions .github/workflows/docker-etherpad.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,24 @@ name: Etherpad Docker Image

env:
REGISTRY: ghcr.io
NAME: etherpad
PROJECTNAME: etherpad

on:
workflow_dispatch:
push:
branches: [ "main" ]
branches: ['main']
paths:
- 'etherpad/*'
- '.github/workflows/*etherpad*'
- '${{env.PROJECTNAME}}/*'
- '.github/workflows/*${{env.PROJECTNAME}}*'
pull_request:
branches: [ "main" ]
branches: ['main']
paths:
- 'etherpad/*'
- '.github/workflows/*etherpad*'
- '${{env.PROJECTNAME}}/*'
- '.github/workflows/*${{env.PROJECTNAME}}*'
schedule:
- cron: '23 1 * * 0' # Sunday at 1:23

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: set release date
run: |
echo "RELEASE_DATE=$(date --rfc-3339=date)" >> ${GITHUB_ENV}

- id: githubactor
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.actor }}
- id: step2
run: echo "IMAGE_NAME=ghcr.io/${{ steps.githubactor.outputs.lowercase }}/${{ env.NAME }}" >> ${GITHUB_ENV}

- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: ./${{ env.NAME }}/
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.RELEASE_DATE }}, ${{ env.IMAGE_NAME }}:latest
labels: ${{ env.RELEASE_DATE }}, latest
include:
- name: Build and Push Image
uses: ./.github/templates/docker-build-template.yml