Publish Docker images #305
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: Publish Docker images | |
on: | |
push: | |
branches: [ master ] | |
schedule: | |
- cron: '0 0 * * 0' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
#version: [latest, 10, 12, 14, 15, 16, 18] | |
#distro: [ buster, bullseye, debian, alpine ] | |
version: [latest, 18] | |
distro: [ bullseye, alpine ] | |
env: | |
repo: "govpf/node" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4.1.7 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.6.1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3.2.0 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Check file existence | |
id: check_files | |
uses: andstor/file-existence-action@v3 | |
with: | |
files: ${{ matrix.version }}/${{ matrix.distro }}/Dockerfile | |
- name: Compute tags | |
if: steps.check_files.outputs.files_exists == 'true' | |
env: | |
repo: ${{ env.repo }} | |
version: ${{ matrix.version }} | |
distro: ${{ matrix.distro }} | |
run: | | |
TAGS="${repo}:${version}-${distro}" | |
if [[ $distro == 'bullseye' ]]; then | |
TAGS+=",${repo}:${version}" | |
fi | |
echo 'docker_tags<<EOF' >> $GITHUB_ENV | |
echo "$TAGS" >> $GITHUB_ENV | |
echo 'EOF' >> $GITHUB_ENV | |
- name: Build | |
if: steps.check_files.outputs.files_exists == 'true' | |
uses: docker/build-push-action@v6.5.0 | |
with: | |
context: . | |
file: ./${{ matrix.version }}/${{ matrix.distro }}/Dockerfile | |
platforms: linux/amd64 | |
pull: true | |
push: true | |
tags: ${{ env.docker_tags }} | |
- name: Update repo description | |
if: steps.check_files.outputs.files_exists == 'true' | |
uses: peter-evans/dockerhub-description@v4.0.0 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
repository: "${{ env.repo }}" |