63 lines
1.7 KiB
YAML
63 lines
1.7 KiB
YAML
name: docker setup and build
|
|
author: tom
|
|
descriptions: setup, login, builds and pushes a container as a package
|
|
inputs:
|
|
path:
|
|
description: 'the path where buildx should start'
|
|
required: false
|
|
default: '.'
|
|
name:
|
|
desciption: 'name of the package'
|
|
required: false
|
|
default: '${{ gitea.repository }}'
|
|
username:
|
|
description: 'username used to push the package'
|
|
required: true
|
|
password:
|
|
description: 'password used to push the package'
|
|
required: true
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: get commit hash
|
|
id: get_hash
|
|
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: git.tmoron.fr
|
|
username: ${{ inputs.username }}
|
|
password: ${{ inputs.password }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: "{{defaultContext}}:${{ input.path }}"
|
|
push: true
|
|
tags: git.tmoron.fr/${{ inputs.name }}:${{ steps.get_hash.outputs.sha_short }}
|
|
|
|
- name: push to latest branch
|
|
run: |
|
|
git config user.name "auto"
|
|
git config user.email "auto@auto.com"
|
|
|
|
if git ls-remote --exit-code --heads origin latest; then
|
|
git switch latest
|
|
git merge master
|
|
else
|
|
git checkout -b latest
|
|
fi
|
|
sed -i -E "s/image: (.*):.*/image: \1:${{ steps.get_hash.outputs.sha_short }}/" deployment.yaml
|
|
git add deployment.yaml
|
|
git commit -m "auto: set image tag in deployment"
|
|
git push origin latest
|