Skip to content

Commit

Permalink
Autopush docker image (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
tycooon committed Jul 20, 2021
1 parent 04a4987 commit 24bb088
Show file tree
Hide file tree
Showing 7 changed files with 1,414 additions and 779 deletions.
7 changes: 6 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
"node": true,
"es6": true
},
"extends": [
"umbrellio",
"plugin:promise/recommended"
],
"rules": {
"quotes": ["error", "double"]
"quotes": ["error", "double"],
"no-console": "off"
}
}
40 changes: 40 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish Docker image

on: [push, pull_request]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
FROM node:alpine

RUN yarn global add @umbrellio/ucdn

ENTRYPOINT ["/usr/local/bin/ucdn"]
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
},
"devDependencies": {
"babel-eslint": "^10.1.0",
"eslint": "^7.3.0"
"eslint": "^7.3.0",
"eslint-config-umbrellio": "^5.0.1",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prefer-object-spread": "^1.2.1",
"eslint-plugin-promise": "^5.1.0"
}
}
6 changes: 3 additions & 3 deletions upload.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require("fs")
const path = require("path")
const mime = require("mime-types")
const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3");
const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3")

const configDefaults = {
region: null,
Expand Down Expand Up @@ -48,7 +48,7 @@ const upload = argv => {
credentials: {
accessKeyId: accessKeyId || "unknown",
secretAccessKey: secretAccessKey || "unknown",
}
},
})

const directory = path.resolve(dir)
Expand All @@ -66,7 +66,7 @@ const upload = argv => {
return Promise.all(promises)
.then(() => {
console.log("Completed")
process.exit(0)
return process.exit(0)
})
.catch(error => {
console.error(error)
Expand Down
2 changes: 1 addition & 1 deletion utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require("path")
const fs = require("fs")
const yaml = require("js-yaml")

const toDashCase = str => str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`);
const toDashCase = str => str.replace(/([A-Z])/g, g => `-${g[0].toLowerCase()}`)

const loadYamlFile = filePath => {
const configPath = path.resolve(filePath)
Expand Down
Loading

0 comments on commit 24bb088

Please sign in to comment.