diff --git a/.forgejo/actions/build-docker/action.yml b/.forgejo/actions/build-docker/action.yml index c83c2ee..79e45c1 100644 --- a/.forgejo/actions/build-docker/action.yml +++ b/.forgejo/actions/build-docker/action.yml @@ -1,4 +1,4 @@ -name: Builds and Publish Docker Image +name: Build and Publish Docker Image description: Define IMAGE_NAME to Git Hub env, based on repository name inputs: username: @@ -18,6 +18,6 @@ runs: - name: Build Docker Image uses: https://git.lhprovedor.com.br/leandro/forgejo-kaniko-action@v2 with: - image: ${{ env.IMAGE_NAME }}:${{ github.sha }},${{ env.IMAGE_NAME }}:latest + image: ${{ inputs.username }}/${{ env.IMAGE_NAME }}:${{ github.sha }},${{ inputs.username }}/${{ env.IMAGE_NAME }}:latest username: ${{ inputs.username }} password: ${{ inputs.password }} diff --git a/.forgejo/actions/deploy-docker/action.yml b/.forgejo/actions/deploy-docker/action.yml new file mode 100644 index 0000000..51c9942 --- /dev/null +++ b/.forgejo/actions/deploy-docker/action.yml @@ -0,0 +1,51 @@ +name: Build and Publish Docker Image +description: Define IMAGE_NAME to Git Hub env, based on repository name +inputs: + username: + description: Registry User Name + required: true + password: + description: Registry Password + required: true +runs: + using: composite + steps: + - name: Configure SSH + uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Configure Staging Server + if: github.ref == 'refs/heads/development' + shell: sh + run: echo demo.lhprovedor.com.br,22 > servidores.lst + + - name: Configure Production Servers + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' + shell: sh + run: | + export SERVIDORES=`curl ${{ secrets.URL_SERVIDORES }}` + echo "Leandro Servidores: $SERVIDORES" + echo $SERVIDORES >> servidores.lst + - name: deploy + shell: sh + run: | + for i in `cat servidores.lst`; do + IP=`echo $i | cut -d , -f 1`; + PORTA=`echo $i | cut -d , -f 2`; + echo "----------------------------------------------------------------------------------------" + echo "-- Syncing $IP:$PORTA" + ssh root@$IP -p $PORTA -o StrictHostKeyChecking=no -t " + cd /lh && docker image prune --force && + docker-compose pull --quiet lhisp-dbupdater && + docker-compose pull --quiet $BITBUCKET_REPO_SLUG && + docker-compose up -d --remove-orphans --force-recreate lhisp-dbupdater + docker-compose up -d --remove-orphans --force-recreate ${{ env.IMAGE_NAME }} + " > $IP-$PORTA.log 2>&1 & + done; + wait + for i in `ls *.log`; do + echo "------------------------------------"; + echo "Arquivo: $i"; + cat $i; + done; diff --git a/.forgejo/actions/set-image-name/action.yml b/.forgejo/actions/set-image-name/action.yml index 1fe5aa7..0d82586 100644 --- a/.forgejo/actions/set-image-name/action.yml +++ b/.forgejo/actions/set-image-name/action.yml @@ -13,9 +13,10 @@ runs: export REPO_FULL=${{ github.repository }} export REPO_NAME=${REPO_FULL#*/} - if [ "${{ github.ref_name }}" != "master" && "${{ github.ref_name }}" != "main" ]; then - export IMAGE_NAME=${{ inputs.username }}/$REPO_NAME-dev + if [ "${{ github.ref_name }}" != "master" ] && [ "${{ github.ref_name }}" != "main" ]; then + export IMAGE_NAME=$REPO_NAME-dev else - export IMAGE_NAME=${{ inputs.username }}/$REPO_NAME + export IMAGE_NAME=$REPO_NAME fi echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV + echo "Image Name: $IMAGE_NAME, for Branch: ${{ github.ref_name }}" diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..eb60b31 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cSpell.words": ["dbupdater", "lhprovedor", "webfactory"] +} diff --git a/force-push.sh b/force-push.sh new file mode 100755 index 0000000..a194e06 --- /dev/null +++ b/force-push.sh @@ -0,0 +1,3 @@ +#/bin/sh + +git add .; git commit --amend --no-edit; git push --force; git tag -d v1; git tag v1; git push --force origin v1; \ No newline at end of file