feature/setup-workflow-pipeline: Extend and improve deploy step #5
@ -1,102 +1,89 @@
|
||||
name: Full Build and Docker Push Workflow
|
||||
run-name: ${{ gitea.actor }} is running a full build and Docker push workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
Builder:
|
||||
runs-on: catthacker-ubuntu-latest
|
||||
steps:
|
||||
- name: Info
|
||||
run: |
|
||||
echo "Triggered by ${{ gitea.event_name }} event"
|
||||
echo "Branch: ${{ gitea.ref }}"
|
||||
echo "Repository: ${{ gitea.repository }}"
|
||||
|
||||
- name: Update apt-get and install Maven
|
||||
run: |
|
||||
apt-get update -y
|
||||
apt-get install -y maven
|
||||
|
||||
- name: Clone the repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
cache: 'maven'
|
||||
|
||||
- name: Build with Maven
|
||||
run: |
|
||||
java -version
|
||||
mvn -version
|
||||
mvn -B clean test -Dspring.profiles.active=test
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
#Build Docker image - Images must follow this naming convention: - {registry}/{owner}/{image}
|
||||
- name: Build Docker image
|
||||
env:
|
||||
GITEA_REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
||||
OWNER: ${{ gitea.actor }}
|
||||
IMAGE_NAME: my-app
|
||||
run: |
|
||||
#docker build -t $GITEA_REGISTRY_URL/$OWNER/my-app:latest .
|
||||
# registry.domain.com/<username>/my-app:latest e.g. git.bepastem.com/eberen/my-app:latest
|
||||
docker build -t $GITEA_REGISTRY_URL/$OWNER/$IMAGE_NAME:latest .
|
||||
|
||||
- name: Build and push Docker image using Buildx
|
||||
env:
|
||||
GITEA_REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
||||
IMAGE_NAME: my-app-backend
|
||||
APP_VERSION: v1.0.0
|
||||
OWNER: ${{ gitea.actor }}
|
||||
LOGIN_TOKEN: ${{ secrets.LOGIN_TOKEN }}
|
||||
run: |
|
||||
docker buildx build --platform linux/amd64 -t $GITEA_REGISTRY_URL/$OWNER/$IMAGE_NAME:$APP_VERSION .
|
||||
#docker buildx build \
|
||||
# --platform linux/amd64 \
|
||||
# #-t $GITEA_REGISTRY_URL/$OWNER/$IMAGE_NAME:latest \
|
||||
# #--push \
|
||||
# .
|
||||
|
||||
- name: Push Docker image to Gitea Registry
|
||||
env:
|
||||
GITEA_USERNAME: ${{ gitea.actor }}
|
||||
LOGIN_TOKEN: ${{ secrets.LOGIN_TOKEN }}
|
||||
GITEA_REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
||||
run: |
|
||||
# Login securely
|
||||
echo "$LOGIN_TOKEN" | docker login $GITEA_REGISTRY_URL --username $GITEA_USERNAME --password-stdin
|
||||
docker push $GITEA_REGISTRY_URL/$GITEA_USERNAME/my-app:latest
|
||||
docker logout $GITEA_REGISTRY_URL
|
||||
|
||||
- name: Cleanup
|
||||
run: |
|
||||
docker images -a
|
||||
docker system prune -f
|
||||
docker images
|
||||
echo "Cleanup done."
|
||||
|
||||
- name: Prepare deploy script
|
||||
run: |
|
||||
mkdir -p .gitea/scripts
|
||||
echo "echo Deploying..." > .gitea/scripts/deploy-backend.sh
|
||||
chmod +x .gitea/scripts/deploy-backend.sh
|
||||
|
||||
- name: Deploy to server via deploy script
|
||||
run: |
|
||||
ls -a
|
||||
ls .gitea/scripts/
|
||||
chmod +x .gitea/scripts/deploy-backend.sh
|
||||
#.gitea/scripts/deploy-backend.sh ${{ gitea.actor }} ${{ vars.REGISTRY_URL }} my-app-backend v1.0.0
|
||||
.gitea/scripts/deploy-backend.sh
|
||||
name: Full Build and Docker Push Workflow
|
||||
run-name: ${{ gitea.actor }} is running a full build and Docker push workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
Builder:
|
||||
runs-on: catthacker-ubuntu-latest
|
||||
steps:
|
||||
- name: Info
|
||||
run: |
|
||||
echo "Triggered by ${{ gitea.event_name }} event"
|
||||
echo "Branch: ${{ gitea.ref }}"
|
||||
echo "Repository: ${{ gitea.repository }}"
|
||||
|
||||
- name: Update apt-get and install Maven
|
||||
run: |
|
||||
apt-get update -y
|
||||
apt-get install -y maven
|
||||
|
||||
- name: Clone the repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
cache: 'maven'
|
||||
|
||||
- name: Build with Maven
|
||||
run: |
|
||||
java -version
|
||||
mvn -version
|
||||
mvn -B clean test -Dspring.profiles.active=test
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
#Build Docker image - Images must follow this naming convention: - {registry}/{owner}/{image}
|
||||
- name: Build Docker image
|
||||
env:
|
||||
GITEA_REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
||||
OWNER: ${{ gitea.actor }}
|
||||
IMAGE_NAME: my-app
|
||||
run: |
|
||||
#docker build -t $GITEA_REGISTRY_URL/$OWNER/my-app:latest .
|
||||
# registry.domain.com/<username>/my-app:latest e.g. git.bepastem.com/eberen/my-app:latest
|
||||
docker build -t $GITEA_REGISTRY_URL/$OWNER/$IMAGE_NAME:latest .
|
||||
|
||||
- name: Build and push Docker image using Buildx
|
||||
env:
|
||||
GITEA_REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
||||
IMAGE_NAME: my-app-backend
|
||||
APP_VERSION: v1.0.0
|
||||
OWNER: ${{ gitea.actor }}
|
||||
LOGIN_TOKEN: ${{ secrets.LOGIN_TOKEN }}
|
||||
run: |
|
||||
docker buildx build --platform linux/amd64 -t $GITEA_REGISTRY_URL/$OWNER/$IMAGE_NAME:$APP_VERSION .
|
||||
#docker buildx build \
|
||||
# --platform linux/amd64 \
|
||||
# #-t $GITEA_REGISTRY_URL/$OWNER/$IMAGE_NAME:latest \
|
||||
# #--push \
|
||||
# .
|
||||
|
||||
- name: Push Docker image to Gitea Registry
|
||||
env:
|
||||
GITEA_USERNAME: ${{ gitea.actor }}
|
||||
LOGIN_TOKEN: ${{ secrets.LOGIN_TOKEN }}
|
||||
GITEA_REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
||||
run: |
|
||||
# Login securely
|
||||
echo "$LOGIN_TOKEN" | docker login $GITEA_REGISTRY_URL --username $GITEA_USERNAME --password-stdin
|
||||
docker push $GITEA_REGISTRY_URL/$GITEA_USERNAME/my-app:latest
|
||||
docker logout $GITEA_REGISTRY_URL
|
||||
|
||||
- name: Cleanup
|
||||
run: |
|
||||
docker images -a
|
||||
docker system prune -f
|
||||
docker images
|
||||
echo "Cleanup done."
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
set -e # Exit immediately if a command exits with a non-zero status
|
||||
|
||||
docker compose -f docker-compose-dev.yml down --remove-orphans --volumes
|
||||
docker compose -f ../../../docker/docker-compose-dev.yml down --remove-orphans --volumes
|
||||
|
||||
docker system prune -f
|
||||
|
||||
|
||||
Reference in New Issue
Block a user