Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
takaishi committed Feb 11, 2025
1 parent cdaca9d commit 8b989ee
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 60 deletions.
64 changes: 35 additions & 29 deletions .github/workflows/build-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,16 @@ jobs:
timeout-minutes: 10
if: github.event.pusher.name != 'dreamkast-cloudnativedays'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
id: buildx
uses: docker/setup-buildx-action@v3

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2

- name: Login to Amazon ECR
- uses: aws-actions/amazon-ecr-login@v2
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs
tags: |
type=sha,prefix=,format=long
type=ref,event=branch
- name: Prepare-tag
id: tags
run: |
Expand All @@ -52,13 +35,13 @@ jobs:
"ARM64" ) arch="arm64" ;;
esac
echo "tag=${{ github.sha }}-${arch}" >> $GITHUB_OUTPUT
- name: Build
id: docker_build
uses: docker/build-push-action@v6
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs:${{ steps.tags.outputs.tag }}
provenance: false
Expand All @@ -67,12 +50,23 @@ jobs:
cache-to: type=gha,mode=max

merge-images:
runs-on:
- "ubuntu-24.04"
- "ubuntu-24.04-arm"
strategy:
matrix:
runs-on:
- "ubuntu-24.04"
- "ubuntu-24.04-arm"
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 10
needs: ["build"]
steps:
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs
tags: |
type=sha,prefix=,format=long
type=ref,event=branch
- name: Prepare-tag
id: tags
run: |
Expand All @@ -83,7 +77,6 @@ jobs:
"ARM64" ) arch="arm64" ;;
esac
echo "tag=${arch}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -101,9 +94,22 @@ jobs:
- name: Create a New Image
run: |
image_tag_sha="${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs:${{ github.sha }}"
docker buildx imagetools create \
--tag ${image_tag_sha} \
${image_tag_sha}-${{ steps.tags.outputs.tag }}
# Create array of image tags from meta output
image_tags=()
for tag in ${{ steps.meta.outputs.tags }}; do
image_tags+=("${tag}-${{ steps.tags.outputs.tag }}")
done
# Join all tags with comma for buildx imagetools create command
joined_tags=$(IFS=,; echo "${image_tags[*]}")
# Create manifest lists for each tag from meta output
for tag in ${{ steps.meta.outputs.tags }}; do
docker buildx imagetools create \
--tag ${tag} \
${image_tag_sha}-${{ steps.tags.outputs.tag }}
# - name: Run Trivy vulnerability scanner
# uses: aquasecurity/trivy-action@master
Expand Down
71 changes: 40 additions & 31 deletions .github/workflows/build-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,24 @@ on:

jobs:
build:
runs-on:
- "ubuntu-24.04"
- "ubuntu-24.04-arm"
strategy:
matrix:
runs-on:
- "ubuntu-24.04"
- "ubuntu-24.04-arm"
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
id: buildx
uses: docker/setup-buildx-action@v3

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-1

- name: Login to Amazon ECR
- uses: aws-actions/amazon-ecr-login@v2
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs
tags: |
type=sha,prefix=,format=long
type=ref,event=tag
- name: Prepare-tag
id: tags
run: |
Expand All @@ -46,7 +34,6 @@ jobs:
"ARM64" ) arch="arm64" ;;
esac
echo "tag=${{ github.sha }}-${arch}" >> $GITHUB_OUTPUT
- name: Build
id: docker_build
uses: docker/build-push-action@v6
Expand All @@ -55,18 +42,30 @@ jobs:
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.meta.outputs.tags }}
tags: ${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs:${{ steps.tags.outputs.tag }}
provenance: false
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

merge-images:
runs-on:
- "ubuntu-24.04"
- "ubuntu-24.04-arm"
strategy:
matrix:
runs-on:
- "ubuntu-24.04"
- "ubuntu-24.04-arm"
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 10
needs: ["build"]
steps:
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs
tags: |
type=sha,prefix=,format=long
type=ref,event=tag
- name: Prepare-tag
id: tags
run: |
Expand All @@ -77,7 +76,6 @@ jobs:
"ARM64" ) arch="arm64" ;;
esac
echo "tag=${arch}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -95,7 +93,18 @@ jobs:
- name: Create a New Image
run: |
image_tag_sha="${{ steps.login-ecr.outputs.registry }}/dreamkast-ecs:${{ github.sha }}"
docker buildx imagetools create \
--tag ${image_tag_sha} \
${image_tag_sha}-${{ steps.tags.outputs.tag }}
# Create array of image tags from meta output
image_tags=()
for tag in ${{ steps.meta.outputs.tags }}; do
image_tags+=("${tag}-${{ steps.tags.outputs.tag }}")
done
# Join all tags with comma for buildx imagetools create command
joined_tags=$(IFS=,; echo "${image_tags[*]}")
# Create manifest lists for each tag from meta output
for tag in ${{ steps.meta.outputs.tags }}; do
docker buildx imagetools create \
--tag ${tag} \
${image_tag_sha}-${{ steps.tags.outputs.tag }}

0 comments on commit 8b989ee

Please sign in to comment.