Skip to content

Commit

Permalink
feat: first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbo2002 committed Jul 26, 2021
1 parent 03ace59 commit c266619
Show file tree
Hide file tree
Showing 14 changed files with 659 additions and 1,286 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
],
"rules": {
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/ban-ts-comment": "off"
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-empty-function": "off"
}
},
{
Expand Down
128 changes: 6 additions & 122 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
${{ runner.os }}-node-
- name: 📦 Install dependencies
run: npm ci
- name: 🐳 Pull alpine image (for unit tests)
run: docker pull alpine
- name: ⏳ Run tests
run: npm run test

Expand All @@ -52,6 +54,8 @@ jobs:
${{ runner.os }}-node-
- name: 📦 Install dependencies
run: npm ci
- name: 🐳 Pull alpine image (for unit tests)
run: docker pull alpine
- name: 🔍 Run linter
run: npm run lint
- name: ⚙️ Build project
Expand Down Expand Up @@ -80,97 +84,6 @@ jobs:
- name: 🕵️‍♀️ Run license checker
run: npm run license-check

docker-image:
name: Build Docker Image
runs-on: ubuntu-latest
env:
PUSH_TO_DOCKERHUB: ${{ (github.repository != 'sebbo2002/js-template') && (secrets.DOCKERHUB_TOKEN != null) }}
steps:
- name: ☁️ Checkout
uses: actions/checkout@v2
- name: 🔧 Set up QEMU
uses: docker/setup-qemu-action@v1
- name: 🔧 Set up Buildx
id: buildx
uses: docker/setup-buildx-action@master
with:
version: "https://github.com/docker/buildx.git#67bd6f4dc82a9cd96f34133dab3f6f7af803bb14"
driver-opts: image=moby/buildkit:master
buildkitd-flags: --debug
- name: 🔐 Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🔐 Login to DockerHub
uses: docker/login-action@v1
if: ${{ env.PUSH_TO_DOCKERHUB == true }}
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: ℹ️ Set Build Variables
id: buildVars
run: echo "::set-output name=date::$(date +'%Y-%m-%d %H:%M:%S')"
- name: 🪄 Build and push (1/2)
uses: docker/build-push-action@v2
with:
context: .
github-token: ${{ secrets.GH_TOKEN }}
target: build-container
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/arm/v7,linux/arm/v6
pull: true
push: true
tags: ghcr.io/${{ github.repository }}:build-container-${{ github.sha }}
cache-from: type=gha
cache-to: type=gha
- name: 🪄 Build and push (2/2)
id: build
uses: docker/build-push-action@v2
with:
context: .
github-token: ${{ secrets.GH_TOKEN }}
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/arm/v7,linux/arm/v6
pull: true
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
labels: |
org.opencontainers.image.authors=${{ github.repository_owner }}
org.opencontainers.image.created=${{ steps.buildVars.outputs.date }}
org.opencontainers.image.ref.name=${{ github.ref }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=https://github.com/${{ github.repository }}
cache-from: |
type=gha
type=registry,ref=ghcr.io/${{ github.repository }}:build-container-${{ github.sha }}
type=registry,ref=ghcr.io/${{ github.repository }}:next
type=registry,ref=ghcr.io/${{ github.repository }}:latest
cache-to: type=gha
- name: 🔄 Push container to DockerHub
if: ${{ env.PUSH_TO_DOCKERHUB == true }}
run: |
docker pull $SOURCE
docker tag $SOURCE $TARGET
docker push $TARGET
env:
SOURCE: ghcr.io/${{ github.repository }}:${{ github.sha }}
TARGET: ${{ github.repository }}:${{ github.sha }}
- name: 🏁 Boot-up Check
if: github.repository != 'sebbo2002/js-template'
run: |
docker run --name "app" -d $IMAGE
sleep 5
docker logs app
docker exec app echo "Ok."
docker stop app
docker rm app
env:
IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
outputs:
digest: ${{ steps.build.outputs.digest }}

release:
name: Release
runs-on: ubuntu-latest
Expand All @@ -180,7 +93,6 @@ jobs:
- coverage
- tests
- license-checker
- docker-image
if: ${{ github.repository != 'sebbo2002/js-template' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') }}
steps:
- name: ☁️ Checkout Project
Expand All @@ -200,34 +112,8 @@ jobs:
run: npm ci
- name: 📂 Create docs folder
run: mkdir ./docs
- name: 🔐 Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🔐 Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: ⬇️ Pull GitHub Containers
id: github
run: |
docker pull "${IMAGE}@${DIGEST}"
echo "::set-output name=image::${IMAGE}@${DIGEST}"
env:
IMAGE: ghcr.io/${{ github.repository }}
DIGEST: ${{ needs.docker-image.outputs.digest }}
- name: ⬇️ Pull Docker Hub Containers
if: ${{ env.PUSH_TO_DOCKERHUB == true }}
id: dockerhub
run: |
docker pull "${IMAGE}@${DIGEST}"
echo "::set-output name=image::${IMAGE}@${DIGEST}"
env:
IMAGE: ${{ github.repository }}
DIGEST: ${{ needs.docker-image.outputs.digest }}
- name: 🐳 Pull alpine image (for unit tests)
run: docker pull alpine
- name: 🪄 Run semantic-release
run: BRANCH=${GITHUB_REF#refs/heads/} npx semantic-release
env:
Expand All @@ -238,8 +124,6 @@ jobs:
GITHUB_NPM_TOKEN: ${{ secrets.GH_TOKEN }}
PUBLIC_NPM_CONFIG_REGISTRY: https://registry.npmjs.org
PUBLIC_NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
DOCKER_LOCAL_IMAGE_GH: ${{ steps.github.outputs.image }}
DOCKER_LOCAL_IMAGE_DH: ${{ steps.dockerhub.outputs.image }}
- name: 🔃 Merge main back into develop
if: ${{ github.ref == 'refs/heads/main' }}
uses: everlytic/[email protected]
Expand Down
6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/semantic-release-docker.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
],
"all": true,
"instrument": true,
"branches": 95,
"lines": 95,
"functions": 95,
"statements": 95,
"branches": 80,
"lines": 80,
"functions": 80,
"statements": 80,
"per-file": true
}
90 changes: 52 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,62 @@
# template
# @sebbo2002/semantic-release-docker

[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)

Here would be a very short description of the project. So in this example it would be a short information that this is
a template that I use to start new projects and services.


## 🚨 Template Usage Checklist
- [ ] Update project name in `package.json`
- [ ] Remove comments in workflow files
- [ ] Create `main` and `develop` branches
- [ ] Set `develop` as default branch
- [ ] Create Docker Repository
- [ ] Add Repository Description
- [ ] Add secret: `DOCKERHUB_TOKEN`
- [ ] Create npm Repository with `npm publish --access public`
- [ ] Add secret: `NPM_TOKEN`
- [ ] Go through repo settings
Small plugin for semantic-release that tags a previously built Docker image and pushes it to one or more Docker
registries. It is assumed that the login has already happened before.


## 📦 Installation

git clone https://github.com/sebbo2002/template.git
cd ./template

npm install


## ⚡️ Quick Start

This is where it would normally say how to use the project.
This could be a code example for a library or instructions on how to use a CLI tool.


## 📑 API-Reference

Is there an API that needs to be documented? Then here would be a nice place for it. If there is external documentation,
you can link it here ([example](https://github.com/sebbo2002/ical-generator/#-api-reference)).


## 🙋 FAQ

### What's `1` + `2`
It's `3` 🎉
npm i --D @sebbo2002/semantic-release-docker


## 🔧 Configuration Example

```js
[
['@sebbo2002/semantic-release-docker', {
images: [
'ghcr.io/sebbo2002/ble2mqtt@sha256:20d67c38e5d1e215413efdca800069998e325669c91a84cba37033866baecc98',
'sebbo2002/ble2mqtt:49055cc3e7292e11e9aa081418e3e5570c1f163a'
],
tag: {
latest: true,
major: true,
minor: true,
version: true,
channel: true
}
}]
]
```

<table>
<tr>
<th scope="row">images</td>
<td>A single image or mutliple images as array. Used as source images to tag.</td>
</tr>
<tr>
<th scope="row">tag.latest</td>
<td>Set to true to create latest tag (except it's a pre-release)</td>
</tr>
<tr>
<th scope="row">tag.major</td>
<td>Set to true to create a major tag (except it's a pre-release, v4.2.9 → image:4)</td>
</tr>
<tr>
<th scope="row">tag.minor</td>
<td>Set to true to create a minor tag (except it's a pre-release, v4.2.9 → image:4.2)</td>
</tr>
<tr>
<th scope="row">tag.version</td>
<td>Set to true to create a minor tag (v4.2.9-develop.1 → image:4.2.9-develop.1)</td>
</tr>
<tr>
<th scope="row">tag.channel</td>
<td>Set to true to create channel tags (v4.2.9-develop.1 in channel next → image:next)</td>
</tr>
</table>


## 🙆🏼‍♂️ Copyright and license
Expand Down
Loading

0 comments on commit c266619

Please sign in to comment.