66
77env :
88 CONDA_CHANNEL : " s3://hls-conda-channels/hls-atmospheric-correction/pr-${{ github.event.pull_request.number }}"
9- CHANNEL_DIR : " channel/ "
9+ CONDA_CHANNEL_HTTP : " https://hls-conda-channels.s3.amazonaws.com/hls-atmospheric-correction/pr-${{ github.event.pull_request.number }} "
1010 # FIXME: for now set "--frozen" since we're having trouble with inconsistent lockfiles
1111 PIXI_FROZEN : true
1212
@@ -44,11 +44,10 @@ jobs:
4444 # ------------------------------------------------------------------
4545 build-and-publish :
4646 needs : analyze
47+ if : needs.analyze.outputs.has_changes == 'true'
4748 runs-on : ubuntu-latest
4849 steps :
4950 - uses : actions/checkout@v4
50- with :
51- ref : ${{ github.event.pull_request.head.ref }}
5251
5352 - uses : prefix-dev/setup-pixi@v0.9.2
5453 with :
@@ -65,40 +64,63 @@ jobs:
6564 aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
6665 aws-region : us-west-2
6766
68- - name : Build and publish packages
69- if : needs.analyze.outputs.has_changes == 'true'
67+ - name : Execute Build Sequence
7068 run : |
71- export CHANNEL_DIR
7269 pixi run -e build \
7370 build-publish-packages \
7471 "${{ needs.analyze.outputs.build_order }}"
7572
73+ # ------------------------------------------------------------------
74+ # JOB 3: Docker Build & Lockfile Update
75+ # ------------------------------------------------------------------
76+ build-docker :
77+ needs : [analyze, build-and-publish]
78+ # Run if Docker changed OR if packages were rebuilt (and build job succeeded)
79+ if : |
80+ always() &&
81+ (needs.analyze.outputs.docker_changed == 'true' || needs.analyze.outputs.has_changes == 'true') &&
82+ (needs.build-and-publish.result == 'success' || needs.build-and-publish.result == 'skipped')
83+ runs-on : ubuntu-latest
84+ steps :
85+ - uses : actions/checkout@v4
86+ with :
87+ ref : ${{ github.event.pull_request.head.ref }}
88+
89+ - uses : prefix-dev/setup-pixi@v0.9.2
90+ with :
91+ frozen : true
92+ environments : build
93+
7694 - name : Update Lockfile
7795 if : needs.analyze.outputs.has_changes == 'true'
7896 run : |
7997 echo "Updating lockfile for: ${{ needs.analyze.outputs.build_order }}"
8098
8199 # Add local package builds to "pr" feature as top priority
82- pixi workspace channel add --no-install --prepend ./${CHANNEL_DIR }
100+ pixi workspace channel add --no-install --prepend ${CONDA_CHANNEL_HTTP }
83101
84102 # Update for these new builds
85103 pixi update --no-install ${{ needs.analyze.outputs.build_order }}
86104
105+ - name : Configure AWS Credentials
106+ uses : aws-actions/configure-aws-credentials@v4
107+ with :
108+ aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
109+ aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
110+ aws-region : us-west-2
111+
87112 - name : Login to Amazon ECR
88- if : needs.analyze.outputs.docker_changed == 'true'
89113 id : login-ecr
90114 uses : aws-actions/amazon-ecr-login@v2
91115
92116 - name : Build and Push Docker Image
93- if : needs.analyze.outputs.docker_changed == 'true'
94117 env :
95118 ECR_REGISTRY : ${{ steps.login-ecr.outputs.registry }}
96119 ECR_REPOSITORY : hls-atmospheric-correction
97120 IMAGE_TAG : ${{ github.event.pull_request.number }}
98121 run : |
99122 docker build \
100123 -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
101- --build-arg CHANNEL_DIR=${CHANNEL_DIR} \
102124 .
103125 docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
104126
0 commit comments