Skip to content

Build and Push to Docker Hub #25

Build and Push to Docker Hub

Build and Push to Docker Hub #25

Workflow file for this run

name: Build and Push to Docker Hub
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: "30 12 * * 0" # Run once every Sunday
env:
REPO: ultraviolet-node
PLATFORMS: linux/amd64,linux/arm64
jobs:
build_and_push_docker_images:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERUSERNAME }}
password: ${{ secrets.DOCKERPASSWORD }}
- name: Build Test Image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.REPO }}
tags: test
containerfiles: |
./docker/Dockerfile
build-args: |
NPM_BUILD=npm ci --omit=dev --frozen-lockfile
- name: Test
run: |
podman run --rm -d -p 8080:8080 localhost/${{ env.REPO }}:test
chmod +x ./docker/test.sh
./docker/test.sh -p 8080 -h 0.0.0.0 -t 15
- name: Install qemu
if: github.event_name != 'pull_request'
run: |
sudo apt-get install -y qemu-user-static
- name: Build Production Images
if: github.event_name != 'pull_request'
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.REPO }}
tags: latest ${{ github.sha }}
containerfiles: |
./docker/Dockerfile
platforms: ${{ env.PLATFORMS }}
build-args: |
NPM_BUILD=npm ci --omit=dev --frozen-lockfile
- name: Push To Docker Hub
if: github.event_name != 'pull_request'
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: docker.io/${{ secrets.DOCKERUSERNAME }}