Skip to content

Add upload-static-assets #406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/upload-static-assets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: upload-static-assets

on:
push:
branches: [main]
paths:
- upload-static-assets/**
- '*.json'
- .github/workflows/upload-static-assets.yaml
pull_request:
branches: [main]
paths:
- upload-static-assets/**
- '*.json'
- .github/workflows/upload-static-assets.yaml

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: ./upload-static-assets
with:
source-image: nginx
source-path: /usr/share/nginx/html
bucket-uri: s3://bucket/dir
7 changes: 7 additions & 0 deletions upload-static-assets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# upload-static-assets

This is an action to extract static assets in a Docker image and upload them to S3 bucket.

## Getting Started

TODO
24 changes: 24 additions & 0 deletions upload-static-assets/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: upload-static-assets
description: upload static assets from Docker image to S3 bucket

inputs:
source-image:
description: source of Docker image
required: true
source-path:
description: source path in the Docker image
required: true
bucket-uri:
description: URI of the destination bucket, e.g. s3://bucket/dir
required: true

runs:
using: composite
steps:
- id: main
shell: bash
run: exec bash ${{ github.action_path }}/main.sh
env:
SOURCE_IMAGE: ${{ inputs.source-image }}
SOURCE_PATH: ${{ inputs.source-path }}
BUCKET_URI: ${{ inputs.bucket-uri }}
19 changes: 19 additions & 0 deletions upload-static-assets/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#/bin/bash
set -o pipefail
set -eux

content_dir="$(mktemp -d)"
container_id="$(docker create "$SOURCE_IMAGE")"
docker cp "$container_id:$SOURCE_PATH" "$content_dir"
docker rm "$container_id"

find "$content_dir" -type f

docker run --rm amazon/aws-cli:latest --version
docker run --rm \
-v /tmp:/tmp \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_SESSION_TOKEN \
amazon/aws-cli:latest \
s3 sync --no-progress "$content_dir" "$BUCKET_URI"