Skip to content

Commit aa7e608

Browse files
authored
Merge pull request #29 from hyperweb-io/anmol/playground-s3
2 parents 4ee141c + b23569e commit aa7e608

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

.github/workflows/s3-action.yaml

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: S3 Playground
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- 'v*.*.*'
8+
workflow_dispatch:
9+
10+
jobs:
11+
upload:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
23+
- name: Configure AWS credentials
24+
uses: aws-actions/configure-aws-credentials@v1
25+
with:
26+
aws-access-key-id: ${{ secrets.S3_PLAYGROUND_ACCESS_KEY_ID }}
27+
aws-secret-access-key: ${{ secrets.S3_PLAYGROUND_SECRET_ACCESS_KEY }}
28+
aws-region: 'us-east-1'
29+
30+
# - name: Install AWS CLI v2
31+
# run: |
32+
# curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o /tmp/awscliv2.zip
33+
# unzip -q /tmp/awscliv2.zip -d /tmp
34+
# rm /tmp/awscliv2.zip
35+
# sudo /tmp/aws/install
36+
# rm -rf /tmp/aws/
37+
38+
- name: Install tar
39+
run: sudo apt-get update && sudo apt-get install -y tar
40+
41+
- name: Determine Archive Name
42+
run: |
43+
# Check if triggered by a tag (e.g., v1.0.0)
44+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
45+
VERSION_TAG="${{ github.ref_name }}"
46+
TARBALL_NAME="${VERSION_TAG}.tar.gz"
47+
else
48+
COMMIT_HASH=$(git rev-parse --short HEAD)
49+
TARBALL_NAME="${COMMIT_HASH}.tar.gz"
50+
fi
51+
echo "TARBALL_NAME=$TARBALL_NAME" >> $GITHUB_ENV
52+
53+
- name: Create Tarball
54+
run: |
55+
# Create a temporary directory
56+
TEMP_DIR=$(mktemp -d)
57+
58+
# Copy everything except .git and node_modules to the temp directory
59+
rsync -a --exclude=".git" --exclude="node_modules" ./ "$TEMP_DIR/"
60+
61+
# Navigate to the temp directory and create the tarball
62+
cd "$TEMP_DIR"
63+
tar --ignore-failed-read -czf "$GITHUB_WORKSPACE/$TARBALL_NAME" ./
64+
65+
# Clean up the temporary directory
66+
rm -rf "$TEMP_DIR"
67+
68+
- name: Upload Tarball to S3
69+
run: |
70+
aws s3 cp "$GITHUB_WORKSPACE/$TARBALL_NAME" "s3://$AWS_S3_BUCKET/create-hyperweb-app/$TARBALL_NAME"
71+
echo "Tarball uploaded: https://$AWS_S3_BUCKET.s3.amazonaws.com/create-hyperweb-app/$TARBALL_NAME"
72+
env:
73+
AWS_DEFAULT_REGION: 'us-east-1'
74+
AWS_ACCESS_KEY_ID: ${{ secrets.S3_PLAYGROUND_ACCESS_KEY_ID }}
75+
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_PLAYGROUND_SECRET_ACCESS_KEY }}
76+
AWS_S3_BUCKET: 'hyperweb-playground'
77+
78+
- name: Update latest.tar.gz (Only on Main)
79+
if: github.ref == 'refs/heads/main'
80+
run: |
81+
aws s3 cp "$GITHUB_WORKSPACE/$TARBALL_NAME" "s3://$AWS_S3_BUCKET/create-hyperweb-app/latest.tar.gz"
82+
echo "Latest tarball updated: https://$AWS_S3_BUCKET.s3.amazonaws.com/create-hyperweb-app/latest.tar.gz"
83+
env:
84+
AWS_DEFAULT_REGION: 'us-east-1'
85+
AWS_ACCESS_KEY_ID: ${{ secrets.S3_PLAYGROUND_ACCESS_KEY_ID }}
86+
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_PLAYGROUND_SECRET_ACCESS_KEY }}
87+
AWS_S3_BUCKET: 'hyperweb-playground'

0 commit comments

Comments
 (0)