Skip to content

Commit b7fdefb

Browse files
authored
Merge pull request #237 from sunya-ch/ci
fix env error in push-to-main ci
2 parents c1b111b + 7827792 commit b7fdefb

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

.github/workflows/push-to-main.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,30 @@ env:
77
TAG: "v0.7.7"
88

99
jobs:
10+
check-branch:
11+
runs-on: ubuntu-latest
12+
13+
outputs:
14+
tag: ${{ steps.image-tag.outputs.tag }}
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Find Image Tag
19+
id: image-tag
20+
env:
21+
BRANCH: ${{ github.ref_name }}
22+
COMMIT: ${{ github.sha }}
23+
run: |
24+
if [ "${{ github.event_name }}" == 'pull_request' ]; then
25+
echo "tag=pr-${{ github.event.number }}" >> "$GITHUB_OUTPUT"
26+
else
27+
if [ "$BRANCH" == "main" ]; then
28+
echo "tag=${{ env.TAG }}" >> "$GITHUB_OUTPUT"
29+
else
30+
echo "tag=$COMMIT" >> "$GITHUB_OUTPUT"
31+
fi
32+
fi
33+
1034
check-change:
1135
runs-on: ubuntu-latest
1236

@@ -31,19 +55,19 @@ jobs:
3155
- '.github/workflows/train-model.yml'
3256
3357
build-push:
34-
needs: [check-change]
58+
needs: [check-change, check-branch]
3559
uses: ./.github/workflows/build-push.yml
3660
with:
3761
base_change: ${{ needs.check-change.outputs.base }}
3862
image_repo: ${{ vars.IMAGE_REPO }}
39-
image_tag: ${{ env.TAG }}
63+
image_tag: ${{ needs.check-branch.outputs.tag }}
4064
push: true
4165
secrets:
4266
docker_username: ${{ secrets.BOT_NAME }}
4367
docker_password: ${{ secrets.BOT_TOKEN }}
4468

4569
train-model:
46-
needs: [check-change, build-push]
70+
needs: [check-change, check-branch, build-push]
4771
if: ${{ needs.check-change.outputs.modeling == 'true' }}
4872
strategy:
4973
matrix:
@@ -54,7 +78,7 @@ jobs:
5478
instance_type: ${{ matrix.instance_type }}
5579
ami_id: 'ami-0e4d0bb9670ea8db0'
5680
github_repo: ${{ github.repository }}
57-
model_server_image: ${{ vars.IMAGE_REPO }}/kepler_model_server:${{ env.TAG }}
81+
model_server_image: ${{ vars.IMAGE_REPO }}/kepler_model_server:${{ needs.check-branch.outputs.tag }}
5882
trainers: LogisticRegressionTrainer,ExponentialRegressionTrainer,SGDRegressorTrainer,GradientBoostingRegressorTrainer,XgboostFitTrainer
5983
secrets:
6084
self_hosted_github_token: ${{ secrets.GH_SELF_HOSTED_RUNNER_TOKEN }}

0 commit comments

Comments
 (0)