All checks were successful
Build and Push Docker Image / docker (push) Successful in 4m9s
56 lines
1.5 KiB
YAML
56 lines
1.5 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Generate tags
|
|
id: vars
|
|
run: |
|
|
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
|
echo "BUILD_DATE=$(date -u +'%Y%m%d-%H%M%S')" >> $GITHUB_ENV
|
|
|
|
- name: Login to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.harryesses.com
|
|
username: ${{ gitea.repository_owner }}
|
|
password: ${{ secrets.PACKAGE_TOKEN }}
|
|
|
|
- name: Set image name
|
|
run: |
|
|
IMAGE_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
|
|
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
|
|
|
|
- name: Build Docker image
|
|
run: |
|
|
docker build \
|
|
-t git.harryesses.com/${IMAGE_NAME}:latest \
|
|
-t git.harryesses.com/${IMAGE_NAME}:${SHORT_SHA} \
|
|
-t git.harryesses.com/${IMAGE_NAME}:${BUILD_DATE} \
|
|
.
|
|
|
|
- name: Push latest tag
|
|
run: |
|
|
docker push git.harryesses.com/${IMAGE_NAME}:latest
|
|
|
|
- name: Push commit hash tag
|
|
run: |
|
|
docker push git.harryesses.com/${IMAGE_NAME}:${SHORT_SHA}
|
|
|
|
- name: Push datetime tag
|
|
run: |
|
|
docker push git.harryesses.com/${IMAGE_NAME}:${BUILD_DATE} |