38 lines
1.1 KiB
YAML
38 lines
1.1 KiB
YAML
name: Build and Push Docker Image
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- gitea_actions
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest # I have self-hosted actions runner :D
|
|
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to Container Registry to push the artifact after build
|
|
run: echo "${{ secrets.CR_passkey }}" | docker login ${{ secrets.CR_endpoint }} -u ${{ secrets.CR_username }} --password-stdin
|
|
|
|
- name: Generate tag for the image
|
|
run: |
|
|
SHA_TAG=${CI_COMMIT_SHA::5}
|
|
IMAGE_TAG_SHA="${{ secrets.CR_endpoint }}/${{ secrets.CR_username }}/${CI_PROJECT_NAME}:latest"
|
|
echo "${SHA_TAG}"
|
|
# IMAGE_TAG_LATEST="${{ secrets.CR_endpoint }}/${{ secrets.CR_username }}/${CI_PROJECT_NAME}:latest"
|
|
|
|
|
|
- name: Build container image
|
|
run: docker build -t $IMAGE_TAG_SHA .
|
|
|
|
- name: Push Docker image to Container Registry
|
|
run: |
|
|
docker push $IMAGE_TAG_SHA
|
|
|
|
|