wireadmin/.github/workflows/docker-image.yaml
Shahrad Elahi 3335f2320d fix
2023-12-01 18:49:08 +03:30

88 lines
2.4 KiB
YAML

name: Build Docker Image
on:
push:
branches:
- "master"
tags:
- "v*.*.*"
jobs:
ghcr-build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
IMAGE_NAME: shahradelahi/wireadmin
steps:
- uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.PRIVATE_TOKEN }}
# If it was a release tag, use the tag as the image tag,
# and otherwise image tag is the commit SHA
- name: Set image tag
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
echo "Labeling image with TAG: ${GITHUB_REF#refs/tags/v}"
echo "IMAGE_TAG=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
echo "RELEASE_TAG=,ghcr.io/${IMAGE_NAME}:latest" >> $GITHUB_ENV
else
echo "Labeling image with commit SHA: ${GITHUB_SHA}"
echo "IMAGE_TAG=${GITHUB_SHA}" >> $GITHUB_ENV
fi
- name: Push to GitHub Container Registry
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}${{ env.RELEASE_TAG }}
docker-build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
IMAGE_NAME: litehex/wireadmin
steps:
- uses: actions/checkout@v3
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set image tag
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
echo "Labeling image with TAG: ${GITHUB_REF#refs/tags/v}"
echo "IMAGE_TAG=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
echo "RELEASE_TAG=,docker.io/${IMAGE_NAME}:latest" >> $GITHUB_ENV
else
echo "Labeling image with commit SHA: ${GITHUB_SHA}"
echo "IMAGE_TAG=${GITHUB_SHA}" >> $GITHUB_ENV
fi
- name: Push to DockerHub
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: docker.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}${{ env.RELEASE_TAG }}