-
Notifications
You must be signed in to change notification settings - Fork 1
54 lines (54 loc) · 2.21 KB
/
push_release_images.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Build and Push Docker Image
env:
IMAGE_NAME: nodebuilder
on:
release:
types: [ published ]
workflow_dispatch:
pull_request:
branches: [ push_docker_images_test ]
jobs:
build-and-push:
name : Push ${{ matrix.config.container }} image
runs-on: ubuntu-latest
strategy:
matrix:
config:
- {container: 'alpine', dockerfile: 'Dockerfile_alpine'}
- {container: 'amazon', dockerfile: 'Dockerfile_amazon'}
- {container: 'arch', dockerfile: 'Dockerfile_arch'}
- {container: 'debian', dockerfile: 'Dockerfile_debian'}
- {container: 'fedora', dockerfile: 'Dockerfile_fedora'}
- {container: 'manjaro', dockerfile: 'Dockerfile_manjaro'}
- {container: 'redhat', dockerfile: 'Dockerfile_redhat'}
- {container: 'ubuntu', dockerfile: 'Dockerfile'}
- {container: 'opensuse', dockerfile: 'Dockerfile_opensuse'}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract tag name
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
echo "NODEBUILDER_VERSION=${GITHUB_REF#refs/tags/}" >> "${GITHUB_ENV}"
else
echo "NODEBUILDER_VERSION=$(git describe --tags --abbrev=0)" >> "${GITHUB_ENV}"
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: docker/${{ matrix.config.dockerfile }}
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ matrix.config.container }}
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ matrix.config.container }}-${{ env.NODEBUILDER_VERSION }}
${{ matrix.config.container == 'ubuntu' && '${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest' || '' }}
${{ matrix.config.container == 'ubuntu' && '${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.NODEBUILDER_VERSION }}' || '' }}