Skip to content

Build Docker Images #378

Build Docker Images

Build Docker Images #378

Workflow file for this run

name: Build Docker Images
on:
workflow_dispatch: # This enables manual triggering
schedule:
- cron: "0 7 * * *"
push:
tags:
- 'v*.*.*'
jobs:
build:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.TOKEN }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch latest tag
id: latesttag
run: echo "version=$(git tag | sort -V | tail -n 1)" >> $GITHUB_ENV
- name: Print latest tag
run: echo "Latest Tag is ${{ env.version }}"
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.TOKEN }}
# Login to Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build Docker Image
run: |
if [[ "${{ env.version }}" != "" ]]; then
docker build \
-t ghcr.io/samcro1967/docker-compose-ports-dump:latest \
-t ghcr.io/samcro1967/docker-compose-ports-dump:${{ env.version }} \
-t osuhickeys/docker-compose-ports-dump:latest \
-t osuhickeys/docker-compose-ports-dump:${{ env.version }} \
.
else
docker build \
-t ghcr.io/samcro1967/docker-compose-ports-dump:latest \
-t osuhickeys/docker-compose-ports-dump:latest \
.
fi
- name: Push Docker Image to GHCR
run: |
docker push ghcr.io/samcro1967/docker-compose-ports-dump:latest
if [[ "${{ env.version }}" != "" ]]; then
docker push ghcr.io/samcro1967/docker-compose-ports-dump:${{ env.version }}
fi
# Push Docker Image to Docker Hub
- name: Push Docker Image to Docker Hub
run: |
docker push osuhickeys/docker-compose-ports-dump:latest
if [[ "${{ env.version }}" != "" ]]; then
docker push osuhickeys/docker-compose-ports-dump:${{ env.version }}
fi
- name: Delete Old Untagged Versions
uses: Chizkiyahu/delete-untagged-ghcr-action@v2
with:
token: ${{ secrets.TOKEN }}
repository_owner: samcro1967
package_name: docker-compose-ports-dump
untagged_only: true
except_untagged_multiplatform: false
owner_type: user