Skip to content

experimental way of binding envvars #757

experimental way of binding envvars

experimental way of binding envvars #757

Workflow file for this run

name: Build
on:
push:
branches:
- master
schedule:
- cron: '0 3 * * *'
jobs:
get-upstream-versions:
strategy:
matrix:
train:
- stable
- testing
runs-on: ubuntu-24.04
steps:
- name: Discover upstream version
uses: ropenttd/cdn_version_scraper@master
with:
channel: ${{ matrix.train }}
id: version
# The following is needed to ensure there isn't a race condition if upstream updates the version between
# this build workflow running, and the manifest workflow running.
# There is still a risk that the version returned by each matrixed architecture run is different,
# but that is (hopefully!) minimal.
- name: Dump upstream train version to file
shell: bash
run: |
echo version=${{steps.version.outputs.version}} >> version.txt
echo semver_major=${{steps.version.outputs.semver_major}} > version.txt
echo semver_minor=${{steps.version.outputs.semver_minor}} > version.txt
echo semver_patch=${{steps.version.outputs.semver_patch}} > version.txt
cat version.txt
- name: Upload upstream train version information
uses: actions/upload-artifact@v4
with:
name: ver-${{ matrix.train }}
path: version.txt
retention-days: 1
overwrite: true
cri:
needs:
- get-upstream-versions
strategy:
matrix:
train:
- stable
- testing
arch:
- os: ubuntu-24.04
name: linux/amd64
label: linux-amd64
- os: ubuntu-24.04-arm
name: linux/arm64
label: linux-arm64
runs-on: ${{ matrix.arch.os }}
steps:
- name: Git checkout
uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Get target version for this train from version phase
uses: actions/download-artifact@v4
with:
name: ver-${{ matrix.train }}
- name: Set target version environment variables
run: |
while read p; do
echo $p >> $GITHUB_ENV
done <version.txt
- name: Generate CRI metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository_owner }}/openttd
docker.io/redditopenttd/openttd
labels: |
org.opencontainers.image.title=OpenTTD
org.opencontainers.image.description=Lightweight build of OpenTTD, designed for server use, with some extra helping treats.
org.opencontainers.image.url=https://github.com/ropenttd/docker_openttd
org.opencontainers.image.source=https://github.com/openttd/openttd
org.opencontainers.image.vendor=Reddit OpenTTD
org.opencontainers.image.version=${{ env.version }}
tags: |
${{ env.version }}-${{ matrix.arch.label }}
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCI
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
build-args: |
OPENTTD_VERSION=${{ env.version }}
platforms: ${{ matrix.arch.name }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
provenance: false
release-bundle-manifest:
needs:
- get-upstream-versions
- cri
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
train:
- stable
- testing
container_store:
- docker
- ghcr
steps:
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Github Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get target version for this train from build phase
uses: actions/download-artifact@v4
with:
name: ver-${{ matrix.train }}
- name: Set target version environment variables
run: |
while read p; do
echo $p >> $GITHUB_ENV
done <version.txt
- name: Create and push manifest (GHCR, stable)
uses: Noelware/docker-manifest-action@0.4.2
if: matrix.train == 'stable' && matrix.container_store == 'ghcr'
with:
inputs: ${{env.GHCR_REPO}}:latest,${{env.GHCR_REPO}}:stable,${{env.GHCR_REPO}}:${{env.version}},${{env.GHCR_REPO}}:${{env.semver_major}}
images: ${{env.GHCR_REPO}}:${{env.version}}-linux-amd64,${{env.GHCR_REPO}}:${{env.version}}-linux-arm64
push: true
- name: Create and push manifest (GHCR, testing)
uses: Noelware/docker-manifest-action@0.4.2
if: matrix.train == 'testing' && matrix.container_store == 'ghcr'
with:
inputs: ${{env.GHCR_REPO}}:testing,${{env.GHCR_REPO}}:${{env.version}}
images: ${{env.GHCR_REPO}}:${{env.version}}-linux-amd64,${{env.GHCR_REPO}}:${{env.version}}-linux-arm64
push: true
- name: Create and push manifest (Docker, stable)
uses: Noelware/docker-manifest-action@0.4.2
if: matrix.train == 'stable' && matrix.container_store == 'docker'
with:
inputs: ${{env.DOCKER_REPO}}:latest,${{env.DOCKER_REPO}}:stable,${{env.DOCKER_REPO}}:${{env.version}},${{env.DOCKER_REPO}}:${{ env.semver_major }}
images: ${{env.DOCKER_REPO}}:${{env.version}}-linux-amd64,${{env.DOCKER_REPO}}:${{env.version}}-linux-arm64
push: true
- name: Create and push manifest (Docker, testing)
uses: Noelware/docker-manifest-action@0.4.2
if: matrix.train == 'testing' && matrix.container_store == 'docker'
with:
inputs: ${{env.DOCKER_REPO}}:testing,${{env.DOCKER_REPO}}:${{env.version}}
images: ${{env.DOCKER_REPO}}:${{env.version}}-linux-amd64,${{env.DOCKER_REPO}}:${{env.version}}-linux-arm64
push: true