Skip to content

Commit edf8dce

Browse files
committed
[release-1] feat: release/*ブランチ下でもdeployするように
1 parent b333309 commit edf8dce

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

.github/workflows/deploy.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ name: Build and Deploy
22

33
on:
44
push:
5-
branches: [main]
5+
branches:
6+
- "**"
7+
pull_request:
8+
branches:
9+
- "**"
610

711
env:
812
REGISTRY: ghcr.io
@@ -49,6 +53,7 @@ jobs:
4953
deploy:
5054
needs: build
5155
runs-on: ubuntu-latest
56+
if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'develop' || startsWith(github.ref_name, 'release/'))
5257
strategy:
5358
matrix:
5459
host: [web01.home, web02.home]
@@ -71,9 +76,9 @@ jobs:
7176
git clone https://github.com/${{ github.repository }}.git /home/ec2-user/2026_team10
7277
fi
7378
cd /home/ec2-user/2026_team10
74-
git fetch origin main
75-
git checkout main
76-
git pull --ff-only origin main
79+
git fetch origin ${{ github.ref_name }}
80+
git checkout ${{ github.ref_name }} || git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
81+
git pull --ff-only origin ${{ github.ref_name }}
7782
echo "${GITHUB_TOKEN}" | docker login ghcr.io -u "${GITHUB_ACTOR}" --password-stdin
7883
docker compose -f docker-compose.yaml pull
7984
docker compose -f docker-compose.yaml up -d --remove-orphans

0 commit comments

Comments
 (0)