Skip to content

Merge pull request #832 from neozhu/test_cicd #686

Merge pull request #832 from neozhu/test_cicd

Merge pull request #832 from neozhu/test_cicd #686

Workflow file for this run

name: Docker Image CI
on:
push:
branches: [ "main" ]
paths-ignore:
- ".github/workflows/deploy/**"
pull_request:
branches: [ "main" ]
paths-ignore:
- ".github/workflows/deploy/**"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Get next version
uses: reecetech/version-increment@2023.9.3
id: version
with:
scheme: semver
increment: patch
- run: git tag ${{ steps.version.outputs.version }}
- run: git push origin ${{ steps.version.outputs.version }}
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Build and push
# uses: docker/build-push-action@v5
# with:
# context: .
# push: true
# tags: blazordevlab/cleanarchitectureblazorserver:${{ steps.version.outputs.version }}
# - name: Build and push with latest tag
# uses: docker/build-push-action@v5
# with:
# context: .
# push: true
# tags: blazordevlab/cleanarchitectureblazorserver:latest
# - name: Update version in docker-compose files
# run: |
# echo "Updating docker-compose files with version ${{ steps.version.outputs.version }}"
# sed -i 's#\(blazordevlab/cleanarchitectureblazorserver:\).*#\1${{ steps.version.outputs.version }}#' .github/workflows/deploy/docker-compose.yml
# sed -i 's#\(blazordevlab/cleanarchitectureblazorserver:\).*#\1${{ steps.version.outputs.version }}#' .github/workflows/deploy/docker-compose-db.yml
- name: Update version in docker-compose files
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
echo "Updating docker-compose files with version ${{ steps.version.outputs.version }}"
sed -i 's#\(blazordevlab/cleanarchitectureblazorserver:\).*#\1${{ steps.version.outputs.version }}#' .github/workflows/deploy/docker-compose.yml
sed -i 's#\(blazordevlab/cleanarchitectureblazorserver:\).*#\1${{ steps.version.outputs.version }}#' .github/workflows/deploy/docker-compose-db.yml
- name: Create Pull Request
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
# Create a new branch with timestamp to avoid conflicts
NEW_BRANCH="update-compose-version-${{ steps.version.outputs.version }}"
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git checkout -b $NEW_BRANCH
# Add, commit changes
git add .github/workflows/deploy/docker-compose.yml .github/workflows/deploy/docker-compose-db.yml
git commit -m "Update Docker Compose files to version ${{ steps.version.outputs.version }}"
git push origin $NEW_BRANCH
- name: Create Pull Request with GitHub CLI
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
GH_TOKEN: ${{ secrets.MY_TOKEN }}
run: |
NEW_BRANCH="update-compose-version-${{ steps.version.outputs.version }}"
gh pr create --base main --head $NEW_BRANCH \
--title "Update Docker Compose to version ${{ steps.version.outputs.version }}" \
--body "Automatically updating Docker Compose version references to match the latest build version ${{ steps.version.outputs.version }}"