Build Docker image #2061
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: Build Docker image | |
on: | |
schedule: | |
- cron: '23 9 * * *' | |
push: | |
branches: [develop] | |
pull_request: | |
branches: [develop] | |
merge_group: | |
jobs: | |
# Push image to GitHub Packages. | |
docker: | |
runs-on: ubuntu-24.04 | |
permissions: | |
contents: read | |
packages: write | |
env: | |
# Check if this is not a pull request andGITHUB_TOKEN is set | |
# As all env variables are strings, you need to compare | |
# against "== 'true'" (not "== true") | |
IS_NOT_PR: "${{ !github.head_ref && true }}" | |
steps: | |
- name: Checkout Sample-Server | |
uses: actions/[email protected] | |
with: | |
path: Sample-Server | |
submodules: recursive | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: PrepareReg Names | |
run: | | |
echo IMAGE_REPOSITORY="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV" | |
echo IMAGE_TAG="$(echo "${{ github.ref }}" | tr '[:upper:]' '[:lower:]' | awk '{sub(/([^\/]*\/){2}/,""); gsub(/\/|_/, "-")}1')" >> "$GITHUB_ENV" | |
echo IS_NOT_PR="${{ env.IS_NOT_PR }})" | |
- name: Login to GitHub Container Registry | |
uses: docker/[email protected] | |
if: github.event_name != 'pull_request' | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Extract metadata (tags, labels) for Docker | |
# https://github.com/docker/metadata-action | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: ghcr.io/${{ env.IMAGE_REPOSITORY }} | |
- name: Build Docker Release | |
uses: "docker/[email protected]" | |
with: | |
provenance: false | |
file: "./Sample-Server/Dockerfile" | |
context: ./Sample-Server | |
platforms: linux/amd64, linux/arm64, linux/arm/v7 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: | | |
ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ env.IMAGE_TAG }} |