diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..02aab8a --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,72 @@ +name: Process redis for auth service + +on: + push: + branches: + - deploy + tags: + - v*.*.* + +jobs: + build: + runs-on: docker-amd64 + + env: + REGISTRY: git.arconlab.ru + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Arch checkout + run: test -f Dockerfile || { echo "Dockerfile not found"; exit 1; } + + - name: Login + run: | + echo "${{ secrets.REGISTRY_TOKEN }}" \ + | docker login $REGISTRY -u ${{ gitea.actor }} --password-stdin + + - name: Set Version + id: version + run: | + REPO=$(echo "${{ gitea.repository }}" | tr '[:upper:]' '[:lower:]') + REF_NAME="${{ gitea.ref_name }}" + REF_TYPE="${{ gitea.ref_type }}" # "branch" или "tag" + + if [ "$REF_TYPE" = "tag" ]; then + VERSION="$REF_NAME" + else + VERSION="${REF_NAME}_latest" + fi + + echo "REPO=$REPO" >> $GITHUB_ENV + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "REF_TYPE=$REF_TYPE" >> $GITHUB_ENV + + + - name: Build Image + run: | + if [ "$REF_TYPE" = "tag" ]; then + docker build --pull --no-cache --provenance=false --sbom=false \ + -t $REGISTRY/$REPO:$VERSION \ + -t $REGISTRY/$REPO:latest \ + . + else + docker build --pull --no-cache --provenance=false --sbom=false \ + -t $REGISTRY/$REPO:$VERSION \ + . + fi + + - name: Push Image + run: | + docker push $REGISTRY/$REPO:$VERSION + if [ "$REF_TYPE" = "tag" ]; then + docker push $REGISTRY/$REPO:latest + fi + + + + - name: Notify success + if: success() + run: | + MESSAGE="Built image: \`${{ env.REGISTRY }}/${{ env.REPO }}:${{ env.VERSION }}\`\nBranch: \`${{ gitea.ref_name }}\`\nCommit: \`${{ gitea.sha }}\`" \ No newline at end of file