forked from IMAP-Science-Operations-Center/sds-data-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (116 loc) · 4.39 KB
/
deploy_dev_containers.yml
File metadata and controls
130 lines (116 loc) · 4.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Build and Deploy Dev Container Images
on:
workflow_dispatch:
inputs:
instruments:
description: 'Instruments to build'
required: true
type: choice
options:
- all
- codice
- glows
- hit
- hi
- ialirt
- idex
- lo
- mag
- spacecraft
- swapi
- swe
- ultra
default: all
git_url:
description: 'IMAP Processing Git URL to build from'
required: false
type: string
default: 'https://github.com/IMAP-Science-Operations-Center/imap_processing.git@dev'
# Prevent multiple builds running concurrently
concurrency:
group: container-build-dev-${{ github.repository }}
cancel-in-progress: false
env:
# IMAP instruments - keep in sync with imap_data_access.VALID_INSTRUMENTS
VALID_INSTRUMENTS: "codice,glows,hit,hi,ialirt,idex,lo,mag,spacecraft,swapi,swe,ultra"
DEV_ACCOUNT: "449431850278"
AWS_REGION: "us-west-2"
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
instruments: ${{ steps.setup.outputs.instruments }}
matrix: ${{ steps.setup.outputs.matrix }}
steps:
- name: Setup build parameters
id: setup
run: |
# Determine which instruments to build
if [ "${{ inputs.instruments }}" = "all" ]; then
instruments="${{ env.VALID_INSTRUMENTS }}"
else
instruments="${{ inputs.instruments }}"
fi
# Clean up whitespace and convert to JSON array
instruments_json=$(echo "$instruments" | tr ',' '\n' | tr -d ' ' | grep -v '^$' | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "instruments=$instruments_json" >> $GITHUB_OUTPUT
echo "matrix={\"instrument\": $instruments_json}" >> $GITHUB_OUTPUT
echo "Building instruments: $instruments_json"
echo "Git URL: ${{ inputs.git_url }}"
build_and_push:
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
fail-fast: false # Continue building other instruments if one fails
permissions:
id-token: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ env.DEV_ACCOUNT }}:role/GitHubDeploy
aws-region: ${{ env.AWS_REGION }}
role-session-name: GitHubActions-${{ matrix.instrument }}-dev
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: "true"
- name: Build, tag, and push docker image to Amazon ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ matrix.instrument }}-repo
IMAGE_TAG: latest
run: |
echo "Building image: $REGISTRY/$REPOSITORY:$IMAGE_TAG"
# Build with dev dockerfile and git URL
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG \
--build-arg GIT_URL=${{ inputs.git_url }} \
-f dockerfiles/Dockerfile.dev .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
echo "✅ Successfully pushed $REGISTRY/$REPOSITORY:$IMAGE_TAG"
summary:
needs: [prepare, build_and_push]
runs-on: ubuntu-latest
if: always()
steps:
- name: Build Summary
run: |
echo "## Dev Container Build Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Environment:** dev" >> $GITHUB_STEP_SUMMARY
echo "**Account:** ${{ env.DEV_ACCOUNT }}" >> $GITHUB_STEP_SUMMARY
echo "**Instruments:** $(echo '${{ needs.prepare.outputs.instruments }}' | jq -r 'join(", ")')" >> $GITHUB_STEP_SUMMARY
echo "**Git URL:** ${{ inputs.git_url }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.build_and_push.result }}" = "success" ]; then
echo "✅ All builds completed successfully" >> $GITHUB_STEP_SUMMARY
elif [ "${{ needs.build_and_push.result }}" = "failure" ]; then
echo "❌ Some builds failed" >> $GITHUB_STEP_SUMMARY
else
echo "⚠️ Build status: ${{ needs.build_and_push.result }}" >> $GITHUB_STEP_SUMMARY
fi