Skip to content

Commit

Permalink
Merge pull request #7 from /issues/6
Browse files Browse the repository at this point in the history
Issues/6
  • Loading branch information
NekitCorp authored Apr 12, 2023
2 parents 79d473d + c57a937 commit 9642a81
Show file tree
Hide file tree
Showing 32 changed files with 50,162 additions and 47,765 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ACCESS_KEY_ID=
SECRET_ACCESS_KEY=
BUCKET=
25 changes: 19 additions & 6 deletions .github/workflows/test-itself.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
name: Test itself

on:
pull_request:
push:
branches: [master]
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node: ["16.x", "18.x"]
name: Node ${{ matrix.node }} sample
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
# Install dependencies
- run: yarn
# Test
- run: yarn test
# Deploy
- uses: ./
with:
access-key-id: ${{ secrets.ACCESS_KEY_ID }}
secret-access-key: ${{ secrets.SECRET_ACCESS_KEY }}
bucket: ${{ secrets.BUCKET }}
include: |
**/*
working-directory: node_modules/@actions/core/lib
exclude: |
.gitignore
yarn.lock
node_modules/**
command.js.map
**/*.d.ts
clear: true
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules
build
.env
.DS_Store
64 changes: 47 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@

## Configuration

| Key | Value | Default | Required |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -------- |
| `access-key-id` | The ID of the key that you received when [generating the static key](https://cloud.yandex.com/en/docs/iam/operations/sa/create-access-key). | | Yes |
| `secret-access-key` | The secret key that you received when [generating the static key](https://cloud.yandex.com/en/docs/iam/operations/sa/create-access-key). | | Yes |
| `bucket` | Bucket name. | | Yes |
| `include` | Include [patterns](https://github.com/isaacs/node-glob#glob-primer) for files. | | Yes |
| `exclude` | Exclude [patterns](https://github.com/isaacs/node-glob#glob-primer) for files. | `[]` | No |
| `clear` | Clear bucket before deploy. | `false` | No |
| Key | Value | Default | Required |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------ | -------- |
| `access-key-id` | The ID of the key that you received when [generating the static key](https://cloud.yandex.com/en/docs/iam/operations/sa/create-access-key). | ||
| `secret-access-key` | The secret key that you received when [generating the static key](https://cloud.yandex.com/en/docs/iam/operations/sa/create-access-key). | ||
| `bucket` | Bucket name. | ||
| `working-directory` | Specify the working directory of where to run the action. The working directory is the directory in which the action is running and is used as the base directory for any relative paths used by the action. | `root project directory` ||
| `include` | Include [patterns](https://github.com/isaacs/node-glob#glob-primer) for files. Collects all files in the `working-directory` by default. | `["**/*"]` ||
| `exclude` | Exclude [patterns](https://github.com/isaacs/node-glob#glob-primer) for files. | `[]` ||
| `clear` | Clear bucket before deploy. | `false` ||

## Example
## Examples

### Hosting full build directory

```yaml
name: Deploy
Expand All @@ -25,14 +28,11 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version: 16
# Build
- run: npm ci
- run: npm run build
Expand All @@ -42,11 +42,41 @@ jobs:
access-key-id: ${{ secrets.ACCESS_KEY_ID }}
secret-access-key: ${{ secrets.SECRET_ACCESS_KEY }}
bucket: ${{ secrets.BUCKET }}
working-directory: build
clear: true
```
### Exclude some files
```yaml
name: Deploy

on:
push:
branches: [main]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
# Build
- run: npm ci
- run: npm run build
# Deploy
- uses: nekitcorp/yandex-storage-website-action@v2
with:
access-key-id: ${{ secrets.ACCESS_KEY_ID }}
secret-access-key: ${{ secrets.SECRET_ACCESS_KEY }}
bucket: ${{ secrets.BUCKET }}
working-directory: build
include: |
**/*
exclude: |
.gitignore
package-lock.json
node_modules/**
clear: true
**/*.d.ts
package.json
README.md
```
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "Yandex object storage static website"
description: "Deploy static website to Yandex Object Storage"
author: "Nikita"
author: "Nikita Madeev"
inputs:
access-key-id:
description: "Service account access key id"
Expand All @@ -17,7 +17,11 @@ inputs:
include:
description: "Include patterns for files"
default: ""
required: true
required: false
working-directory:
description: "Specify the working directory of where to run the command"
default: ""
required: false
exclude:
description: "Exclude patterns for files"
default: ""
Expand Down
14 changes: 9 additions & 5 deletions src/dev.ts → dev.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import dotenv from "dotenv";
import { S3Uploader } from "./s3-uploader";
import { AWSS3Client } from "./src/aws-s3-client";
import { FilesManager } from "./src/files-manager";
import { S3Uploader } from "./src/s3-uploader";

dotenv.config();

Expand All @@ -14,19 +16,21 @@ if (!process.env.BUCKET) {
}

const s3Uploader = new S3Uploader(
{
new AWSS3Client({
accessKeyId: process.env.ACCESS_KEY_ID,
endpoint: "https://storage.yandexcloud.net",
secretAccessKey: process.env.SECRET_ACCESS_KEY,
},
bucket: process.env.BUCKET,
}),
new FilesManager(),
console.log
);

s3Uploader
.upload({
bucket: process.env.BUCKET,
clear: true,
workingDirectory: "node_modules/@actions/core/lib",
include: ["**/*"],
exclude: [".gitignore", "yarn.lock", "node_modules/**"],
exclude: ["command.js.map", "**/*.d.ts"],
})
.catch((err) => console.error(err));
Loading

0 comments on commit 9642a81

Please sign in to comment.