push to registry
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
name: Build & Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
tags: [ 'v*' ]
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: host
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
run: |
|
||||
rm -rf * .git* 2>/dev/null || true
|
||||
git clone https://gitea.skalas.org/jskala/NFOguard.git /tmp/repo
|
||||
cp -r /tmp/repo/* .
|
||||
cp -r /tmp/repo/.* . 2>/dev/null || true
|
||||
rm -rf /tmp/repo
|
||||
|
||||
- name: Set up variables
|
||||
run: |
|
||||
# Get version from tag or use 'latest'
|
||||
if [[ ${{ github.ref }} == refs/tags/* ]]; then
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
else
|
||||
VERSION=latest
|
||||
fi
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
echo "Building version: $VERSION"
|
||||
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
docker build -t nfoguard:${{ env.VERSION }} .
|
||||
docker tag nfoguard:${{ env.VERSION }} nfoguard:latest
|
||||
|
||||
- name: Push to GitHub Container Registry
|
||||
run: |
|
||||
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
docker tag nfoguard:${{ env.VERSION }} ghcr.io/jskala/nfoguard:${{ env.VERSION }}
|
||||
docker tag nfoguard:${{ env.VERSION }} ghcr.io/jskala/nfoguard:latest
|
||||
docker push ghcr.io/jskala/nfoguard:${{ env.VERSION }}
|
||||
docker push ghcr.io/jskala/nfoguard:latest
|
||||
|
||||
- name: Push to Docker Hub
|
||||
run: |
|
||||
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
|
||||
docker tag nfoguard:${{ env.VERSION }} jskala/nfoguard:${{ env.VERSION }}
|
||||
docker tag nfoguard:${{ env.VERSION }} jskala/nfoguard:latest
|
||||
docker push jskala/nfoguard:${{ env.VERSION }}
|
||||
docker push jskala/nfoguard:latest
|
||||
|
||||
- name: Update distribution repo
|
||||
run: |
|
||||
# Clone the distribution repo
|
||||
git clone https://github.com/jskala/NFOguard-Deploy.git /tmp/deploy
|
||||
cd /tmp/deploy
|
||||
|
||||
# Update docker-compose.yml with new version
|
||||
sed -i "s|image: .*nfoguard:.*|image: ghcr.io/jskala/nfoguard:${{ env.VERSION }}|" docker-compose.yml
|
||||
|
||||
# Update README with new version info
|
||||
sed -i "s/Latest Version: .*/Latest Version: ${{ env.VERSION }}/" README.md
|
||||
|
||||
# Commit and push changes
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
git add .
|
||||
git commit -m "Update to version ${{ env.VERSION }}" || exit 0
|
||||
git push
|
||||
Reference in New Issue
Block a user