|
1 | | -name: Build and Push to AWS ECR Public |
2 | | - |
| 1 | +name: Build and Push GPU CUDA Image |
3 | 2 | on: |
4 | 3 | push: |
5 | 4 | branches: |
6 | 5 | - master |
7 | 6 | paths: |
8 | 7 | - 'gpu-cuda/**' |
9 | | - - '.github/workflows/build-gpu-cuda.yml' |
| 8 | + - '.github/workflows/build.yml' |
10 | 9 | pull_request: |
11 | 10 | branches: |
12 | 11 | - master |
13 | 12 | paths: |
14 | 13 | - 'gpu-cuda/**' |
15 | | - - '.github/workflows/build-gpu-cuda.yml' |
| 14 | + - '.github/workflows/build.yml' |
16 | 15 | workflow_dispatch: |
17 | 16 | inputs: |
18 | 17 | tag: |
19 | 18 | description: 'Image tag' |
20 | 19 | required: false |
21 | 20 | default: 'latest' |
22 | 21 |
|
23 | | -env: |
24 | | - AWS_REGION: us-east-1 |
25 | | - REPOSITORY_NAME: jupyter-docker |
26 | | - IMAGE_NAME: codio/codio-jupyter |
27 | | - TAG_PREFIX: gpu-cuda |
28 | | - ECR_REGISTRY: public.ecr.aws/o0g3m8o6 |
29 | | - |
30 | 22 | jobs: |
31 | | - build-and-push: |
32 | | - runs-on: ubuntu-latest |
33 | | - permissions: |
34 | | - id-token: write |
35 | | - contents: read |
36 | | - |
37 | | - steps: |
38 | | - - name: Checkout code |
39 | | - uses: actions/checkout@v6 |
40 | | - with: |
41 | | - fetch-depth: 0 |
42 | | - |
43 | | - - name: Configure AWS Credentials |
44 | | - uses: aws-actions/configure-aws-credentials@main |
45 | | - with: |
46 | | - aws-region: us-east-1 |
47 | | - role-to-assume: arn:aws:iam::878986216776:role/Github/GithubECRPublicUploadRole_${{ env.REPOSITORY_NAME }} |
48 | | - role-session-name: GithubAction |
49 | | - |
50 | | - - name: Login to Amazon ECR |
51 | | - id: login-ecr |
52 | | - uses: aws-actions/amazon-ecr-login@v2 |
53 | | - with: |
54 | | - registry-type: public |
55 | | - |
56 | | - |
57 | | - - name: Set up Docker Buildx |
58 | | - uses: docker/setup-buildx-action@v3 |
59 | | - |
60 | | - - name: Create and use a new builder instance |
61 | | - run: | |
62 | | - docker buildx create --name ga-builder --use |
63 | | -
|
64 | | - - name: Set image tags |
65 | | - id: meta |
66 | | - run: | |
67 | | - ECR_REGISTRY="${{ env.ECR_REGISTRY }}" |
68 | | - SHA_SHORT=${{ env.TAG_PREFIX }}-$(echo ${{ github.sha }} | cut -c1-7) |
69 | | -
|
70 | | - if [ "${{ github.event_name }}" == "pull_request" ]; then |
71 | | - IMAGE_TAG="${{ env.TAG_PREFIX }}-${{ github.event.pull_request.head.ref }}" |
72 | | - else |
73 | | - IMAGE_TAG="${{ env.TAG_PREFIX }}-${{ github.event.inputs.tag || 'latest' }}" |
74 | | - TIMESTAMP=${{ env.TAG_PREFIX }}-$(date +%Y%m%d) |
75 | | - echo "timestamp=${TIMESTAMP}" >> $GITHUB_OUTPUT |
76 | | - fi |
77 | | -
|
78 | | - echo "ecr_registry=${ECR_REGISTRY}" >> $GITHUB_OUTPUT |
79 | | - echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT |
80 | | - echo "sha_short=${SHA_SHORT}" >> $GITHUB_OUTPUT |
81 | | -
|
82 | | - TAGS="${ECR_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG},${ECR_REGISTRY}/${IMAGE_NAME}:${SHA_SHORT}" |
83 | | -
|
84 | | - if [ "${{ github.event_name }}" != "pull_request" ]; then |
85 | | - TAGS="${TAGS},${ECR_REGISTRY}/${IMAGE_NAME}:${TIMESTAMP}" |
86 | | - fi |
87 | | -
|
88 | | - echo "tags=${TAGS}" >> $GITHUB_OUTPUT |
89 | | -
|
90 | | - - name: Build and push Docker image |
91 | | - uses: docker/build-push-action@v6 |
92 | | - timeout-minutes: 30 |
93 | | - with: |
94 | | - context: ./gpu-cuda |
95 | | - push: true |
96 | | - tags: ${{ steps.meta.outputs.tags }} |
97 | | - builder: ga-builder |
98 | | - cache-from: type=registry,ref=${{ steps.meta.outputs.ecr_registry }}/${{ env.IMAGE_NAME }}:cache |
99 | | - cache-to: type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=${{ steps.meta.outputs.ecr_registry }}/${{ env.IMAGE_NAME }}:cache |
100 | | - |
101 | | - - name: Image summary |
102 | | - run: | |
103 | | - { |
104 | | - echo "### Docker Image Published :rocket:" |
105 | | - echo "event name: ${{ github.event_name }}" |
106 | | - echo "" |
107 | | - echo "**Registry:** ${{ steps.meta.outputs.ecr_registry }}" |
108 | | - echo "**Image:** ${IMAGE_NAME}" |
109 | | - echo "" |
110 | | - echo "**Tags:**" |
111 | | - echo "- \`${{ steps.meta.outputs.image_tag }}\`" |
112 | | - echo "- \`${{ steps.meta.outputs.timestamp || 'Timestamp tag is not available for PR' }}\`" |
113 | | - echo "- \`${{ steps.meta.outputs.sha_short }}\`" |
114 | | - echo "" |
115 | | - echo "**Pull command:**" |
116 | | - echo "\`\`\`bash" |
117 | | - echo "docker pull ${{ steps.meta.outputs.ecr_registry }}/${IMAGE_NAME}:${{ steps.meta.outputs.image_tag }}" |
118 | | - echo "\`\`\`" |
119 | | - } | tee -a $GITHUB_STEP_SUMMARY |
| 23 | + call-build: |
| 24 | + uses: ./.github/workflows/build.yml |
| 25 | + with: |
| 26 | + prefix: gpu-cuda |
0 commit comments