| 1 |
# This workflow uses actions that are not certified by GitHub.
|
| 2 |
# They are provided by a third-party and are governed by
|
| 3 |
# separate terms of service, privacy policy, and support
|
| 4 |
# documentation.
|
| 5 |
|
| 6 |
# GitHub recommends pinning actions to a commit SHA.
|
| 7 |
# To get a newer version, you will need to update the SHA.
|
| 8 |
# You can also reference a tag or branch, but the action may change without warning.
|
| 9 |
|
| 10 |
name: Publish Docker image
|
| 11 |
|
| 12 |
on:
|
| 13 |
push:
|
| 14 |
branches: [ "milestone" ]
|
| 15 |
schedule:
|
| 16 |
# Run every day 05:10 UTC+8
|
| 17 |
- cron: '10 21 * * *'
|
| 18 |
|
| 19 |
env:
|
| 20 |
DOCKERHUB_PLATFORMS: linux/amd64,linux/arm64
|
| 21 |
APACHE_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/lbbs-apache
|
| 22 |
PHP_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/lbbs-php
|
| 23 |
BBSD_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/lbbs-bbsd
|
| 24 |
|
| 25 |
jobs:
|
| 26 |
push_to_registry:
|
| 27 |
name: Push Docker image to Docker Hub
|
| 28 |
runs-on: ubuntu-latest
|
| 29 |
permissions:
|
| 30 |
packages: write
|
| 31 |
contents: read
|
| 32 |
attestations: write
|
| 33 |
id-token: write
|
| 34 |
steps:
|
| 35 |
- name: Set current date as env variable
|
| 36 |
run: echo "BUILD_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV
|
| 37 |
|
| 38 |
- name: Checkout repository and submodules
|
| 39 |
uses: actions/checkout@v4
|
| 40 |
with:
|
| 41 |
submodules: recursive
|
| 42 |
fetch-depth: 0 # fetch all history if the action needs it
|
| 43 |
|
| 44 |
- name: Log in to Docker Hub
|
| 45 |
uses: docker/login-action@v3
|
| 46 |
with:
|
| 47 |
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
| 48 |
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
| 49 |
|
| 50 |
- name: Set up QEMU
|
| 51 |
uses: docker/setup-qemu-action@v3
|
| 52 |
|
| 53 |
- name: Set up Docker Buildx
|
| 54 |
uses: docker/setup-buildx-action@v3
|
| 55 |
|
| 56 |
- name: Build the Docker image (apache)
|
| 57 |
id: push-apache
|
| 58 |
uses: docker/build-push-action@v5
|
| 59 |
with:
|
| 60 |
platforms: ${{ env.DOCKERHUB_PLATFORMS }}
|
| 61 |
context: .
|
| 62 |
file: Dockerfile/dockerfile.apache.testing
|
| 63 |
push: true
|
| 64 |
tags: |
|
| 65 |
${{ env.APACHE_IMAGE }}:testing-${{ env.BUILD_DATE }}
|
| 66 |
${{ env.APACHE_IMAGE }}:testing
|
| 67 |
labels: ${{ steps.meta.outputs.labels }}
|
| 68 |
|
| 69 |
- name: Build the Docker image (php)
|
| 70 |
id: push-php
|
| 71 |
uses: docker/build-push-action@v5
|
| 72 |
with:
|
| 73 |
platforms: ${{ env.DOCKERHUB_PLATFORMS }}
|
| 74 |
context: .
|
| 75 |
file: Dockerfile/dockerfile.php.testing
|
| 76 |
push: true
|
| 77 |
tags: |
|
| 78 |
${{ env.PHP_IMAGE }}:testing-${{ env.BUILD_DATE }}
|
| 79 |
${{ env.PHP_IMAGE }}:testing
|
| 80 |
labels: ${{ steps.meta.outputs.labels }}
|
| 81 |
|
| 82 |
- name: Build the Docker image (bbsd)
|
| 83 |
id: push-bbsd
|
| 84 |
uses: docker/build-push-action@v5
|
| 85 |
with:
|
| 86 |
platforms: ${{ env.DOCKERHUB_PLATFORMS }}
|
| 87 |
context: .
|
| 88 |
file: Dockerfile/dockerfile.bbsd.testing
|
| 89 |
push: true
|
| 90 |
tags: |
|
| 91 |
${{ env.BBSD_IMAGE }}:testing-${{ env.BUILD_DATE }}
|
| 92 |
${{ env.BBSD_IMAGE }}:testing
|
| 93 |
labels: ${{ steps.meta.outputs.labels }}
|