ci: push container image to gitea registry on success
This commit is contained in:
@@ -24,3 +24,29 @@ jobs:
|
||||
- run: |
|
||||
go mod tidy
|
||||
git diff --exit-code go.mod go.sum
|
||||
publish:
|
||||
name: Publish Docker Image
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push'
|
||||
needs: [build, tidy]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Log in to Gitea container registry
|
||||
run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login gitea.stevedudenhoeffer.com --username "${{ secrets.REGISTRY_USER }}" --password-stdin
|
||||
- name: Build and push Docker image
|
||||
run: |
|
||||
BRANCH="${{ github.ref_name }}"
|
||||
SAFE_BRANCH="${BRANCH//\//-}"
|
||||
REGISTRY="gitea.stevedudenhoeffer.com/steve/foreman"
|
||||
|
||||
docker build -t "${REGISTRY}:${SAFE_BRANCH}" .
|
||||
|
||||
if [ "${BRANCH}" = "main" ]; then
|
||||
docker tag "${REGISTRY}:${SAFE_BRANCH}" "${REGISTRY}:latest"
|
||||
fi
|
||||
|
||||
docker push "${REGISTRY}:${SAFE_BRANCH}"
|
||||
|
||||
if [ "${BRANCH}" = "main" ]; then
|
||||
docker push "${REGISTRY}:latest"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user