Some checks failed
Build and Push Docker Image / docker (push) Has been cancelled
57 lines
1.6 KiB
YAML
57 lines
1.6 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- master
|
|
|
|
jobs:
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Install dependencies
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y git docker.io
|
|
|
|
- name: Clone repository
|
|
run: |
|
|
git clone ${{ github.server_url }}/${{ github.repository }} repo
|
|
cd repo
|
|
git checkout ${{ github.sha }}
|
|
|
|
- name: Generate tags
|
|
run: |
|
|
cd repo
|
|
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
|
|
run: |
|
|
echo "${{ secrets.GITEA_TOKEN }}" | docker login \
|
|
${{ github.server_url }} \
|
|
-u "${{ github.actor }}" \
|
|
--password-stdin
|
|
|
|
- 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: |
|
|
cd repo
|
|
|
|
docker build \
|
|
-t ${{ github.server_url }}/${IMAGE_NAME}:latest \
|
|
-t ${{ github.server_url }}/${IMAGE_NAME}:${SHORT_SHA} \
|
|
-t ${{ github.server_url }}/${IMAGE_NAME}:${BUILD_DATE} \
|
|
.
|
|
|
|
- name: Push images
|
|
run: |
|
|
docker push ${{ github.server_url }}/${IMAGE_NAME}:latest
|
|
docker push ${{ github.server_url }}/${IMAGE_NAME}:${SHORT_SHA}
|
|
docker push ${{ github.server_url }}/${IMAGE_NAME}:${BUILD_DATE} |