diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index e252410..5a409dc 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -49,9 +49,10 @@ jobs: release: name: Semantic Release runs-on: ubuntu-latest - needs: build env: GITEA_TOKEN: ${{ secrets.CI_GITEA_TOKEN }} + IMAGE_NAME: ${{ inputs.image-name }} + REGISTRY_URL: ${{ inputs.registry-url }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -73,7 +74,26 @@ jobs: GIT_AUTHOR_EMAIL: "ci@etwo.dev" GIT_COMMITTER_NAME: "CI Bot" GIT_COMMITTER_EMAIL: "ci@etwo.dev" - IMAGE_NAME: ${{ inputs.image-name }} + + - name: Install yq + run: | + wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq + chmod +x /usr/bin/yq + + - name: Update docker-compose.yml + run: | + VERSION=$(cat .release-version) + echo "Updating docker-compose.yml with image ${IMAGE_NAME}:${VERSION}" + yq -i ".services.\"${IMAGE_NAME}\".image = \"${REGISTRY_URL}/${IMAGE_NAME}:${VERSION}\"" docker-compose.yml + + - name: Commit and push docker-compose.yml changes + run: | + VERSION=$(cat .release-version) + git config user.name "CI Bot" + git config user.email "ci@etwo.dev" + git add docker-compose.yml + git commit -m "chore(release): update compose to ${VERSION} [skip ci]" || echo "No changes to commit" + git push origin HEAD # -------------------------------------------------------- # Build and Push Docker Image @@ -81,6 +101,7 @@ jobs: build: name: Build and Push Docker Image runs-on: ubuntu-latest + needs: release env: IMAGE_NAME: ${{ inputs.image-name }} REGISTRY_URL: ${{ inputs.registry-url }} @@ -96,7 +117,7 @@ jobs: - name: Build Docker image run: | - VERSION=$(cat .release-version 2>/dev/null || echo "latest") + VERSION=$(cat .release-version || echo "latest") echo "Building docker image with tag $VERSION" docker build -t $REGISTRY_URL/${IMAGE_NAME}:$VERSION . docker push $REGISTRY_URL/${IMAGE_NAME}:$VERSION @@ -107,13 +128,13 @@ jobs: deploy: name: Deploy to Portainer runs-on: ubuntu-latest - needs: release + needs: build steps: - name: Checkout repository uses: actions/checkout@v4 - name: Deploy stack via Portainer API - uses: actions/portable@v1 + uses: https://git.etwo.dev/actions/portable@v1 with: portainer-url: ${{ inputs.portainer-url }} portainer-token: ${{ secrets.PORTAINER_TOKEN }}