
Some checks failed
Deploy to Production, build images and push to Gitea Registry / build_and_push (pull_request) Failing after 24s
113 lines
4.0 KiB
YAML
113 lines
4.0 KiB
YAML
name: Deploy to Production, build images and push to Gitea Registry
|
|
|
|
on:
|
|
pull_request:
|
|
types: [closed]
|
|
branches:
|
|
- prod
|
|
|
|
jobs:
|
|
build_and_push:
|
|
if: github.event.pull_request.merged == true
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install Docker
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y docker.io
|
|
|
|
- name: Debug context variables
|
|
run: |
|
|
echo "Actor: ${{ gitea.actor }}"
|
|
echo "Repository: ${{ gitea.repository_name }}"
|
|
echo "Repository owner: ${{ gitea.repository_owner }}"
|
|
echo "Event repository name: ${{ gitea.event.repository.name }}"
|
|
echo "Event repository full name: ${{ gitea.event.repository.full_name }}"
|
|
|
|
- name: Build and push backend image
|
|
env:
|
|
GITEA_USERNAME: ${{ secrets.ME_USERNAME }}
|
|
GITEA_PASSWORD: ${{ secrets.ME_PASSWORD }}
|
|
run: |
|
|
echo $GITEA_PASSWORD | docker login git.vinylnostalgia.com -u $GITEA_USERNAME --password-stdin
|
|
|
|
# Try different context variable combinations
|
|
REPO_NAME="${{ gitea.repository_name }}"
|
|
ACTOR="${{ gitea.actor }}"
|
|
OWNER="${{ gitea.repository_owner }}"
|
|
|
|
# Use fallback if variables are empty
|
|
if [ -z "$REPO_NAME" ]; then
|
|
REPO_NAME="${{ gitea.event.repository.name }}"
|
|
fi
|
|
if [ -z "$ACTOR" ]; then
|
|
ACTOR="${{ gitea.event.repository.owner.login }}"
|
|
fi
|
|
|
|
echo "Using ACTOR: $ACTOR"
|
|
echo "Using REPO_NAME: $REPO_NAME"
|
|
|
|
# Build with compression
|
|
docker build --compress -t git.vinylnostalgia.com/$ACTOR/$REPO_NAME-backend:latest ./be -f ./be/Dockerfile.prod
|
|
|
|
# Save image to tar file
|
|
docker save git.vinylnostalgia.com/$ACTOR/$REPO_NAME-backend:latest > backend.tar
|
|
|
|
# Split the tar file into smaller chunks (100MB each)
|
|
split -b 100M backend.tar backend.tar.part_
|
|
|
|
# Push each chunk
|
|
for chunk in backend.tar.part_*; do
|
|
docker load < "$chunk"
|
|
docker push git.vinylnostalgia.com/$ACTOR/$REPO_NAME-backend:latest
|
|
sleep 5 # Add delay between pushes
|
|
done
|
|
|
|
# Cleanup
|
|
rm backend.tar backend.tar.part_*
|
|
|
|
- name: Build and push frontend image
|
|
env:
|
|
GITEA_USERNAME: ${{ secrets.ME_USERNAME }}
|
|
GITEA_PASSWORD: ${{ secrets.ME_PASSWORD }}
|
|
run: |
|
|
echo $GITEA_PASSWORD | docker login git.vinylnostalgia.com -u $GITEA_USERNAME --password-stdin
|
|
|
|
# Try different context variable combinations
|
|
REPO_NAME="${{ gitea.repository_name }}"
|
|
ACTOR="${{ gitea.actor }}"
|
|
OWNER="${{ gitea.repository_owner }}"
|
|
|
|
# Use fallback if variables are empty
|
|
if [ -z "$REPO_NAME" ]; then
|
|
REPO_NAME="${{ gitea.event.repository.name }}"
|
|
fi
|
|
if [ -z "$ACTOR" ]; then
|
|
ACTOR="${{ gitea.event.repository.owner.login }}"
|
|
fi
|
|
|
|
echo "Using ACTOR: $ACTOR"
|
|
echo "Using REPO_NAME: $REPO_NAME"
|
|
|
|
# Build with compression
|
|
docker build --compress -t git.vinylnostalgia.com/$ACTOR/$REPO_NAME-frontend:latest ./fe -f ./fe/Dockerfile.prod
|
|
|
|
# Save image to tar file
|
|
docker save git.vinylnostalgia.com/$ACTOR/$REPO_NAME-frontend:latest > frontend.tar
|
|
|
|
# Split the tar file into smaller chunks (100MB each)
|
|
split -b 100M frontend.tar frontend.tar.part_
|
|
|
|
# Push each chunk
|
|
for chunk in frontend.tar.part_*; do
|
|
docker load < "$chunk"
|
|
docker push git.vinylnostalgia.com/$ACTOR/$REPO_NAME-frontend:latest
|
|
sleep 5 # Add delay between pushes
|
|
done
|
|
|
|
# Cleanup
|
|
rm frontend.tar frontend.tar.part_* |