Add .gitea/workflows/image-publish.yml
This commit is contained in:
56
.gitea/workflows/image-publish.yml
Normal file
56
.gitea/workflows/image-publish.yml
Normal file
@@ -0,0 +1,56 @@
|
||||
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}
|
||||
Reference in New Issue
Block a user