mirror of
https://github.com/amark/gun.git
synced 2026-03-11 19:24:50 +00:00
cleaning up and improving the CI/CD pipeline (#1122)
* no artifacts, not required * renamed * cleanup and comments * pass build args * two-step docker build
This commit is contained in:
49
.github/workflows/ci.yml
vendored
49
.github/workflows/ci.yml
vendored
@@ -1,20 +1,23 @@
|
||||
name: ci
|
||||
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
env:
|
||||
project: 'release-node'
|
||||
project: 'gun'
|
||||
|
||||
jobs:
|
||||
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [14.x] # [12.x, 14.x]
|
||||
os: [ubuntu-latest] #, macos-latest, windows-latest]
|
||||
node-version: [ 14.x ]
|
||||
os: [ ubuntu-latest ]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
|
||||
# checkout the code
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
@@ -22,11 +25,13 @@ jobs:
|
||||
- name: Version
|
||||
uses: tcurdt/action-verify-version-npm@master
|
||||
|
||||
# setup the node version
|
||||
- name: Setup Node ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
# cache node_modules if we can
|
||||
- name: Cache
|
||||
id: cache-modules
|
||||
uses: actions/cache@v2
|
||||
@@ -34,42 +39,24 @@ jobs:
|
||||
path: node_modules
|
||||
key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('package.json') }}
|
||||
|
||||
# ottherweise run install
|
||||
- name: Install
|
||||
if: steps.cache-modules.outputs.cache-hit != 'true'
|
||||
run: npm install
|
||||
|
||||
# run tests
|
||||
- name: Test
|
||||
run: npm test
|
||||
|
||||
# create release artifacts to publish as github release
|
||||
# - name: Upload
|
||||
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
||||
# uses: actions/upload-artifact@v2
|
||||
# with:
|
||||
# name: ${{ env.project }}_${{ matrix.os }}_${{ matrix.node-version }}
|
||||
# path: |
|
||||
# !.git
|
||||
# !.github
|
||||
# !node_modules
|
||||
# .
|
||||
|
||||
# only create a release for tags named 'v*'
|
||||
release:
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
||||
needs: [test]
|
||||
needs: [ test ]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
# - name: Download
|
||||
# uses: actions/download-artifact@v2
|
||||
# with:
|
||||
# path: artifacts
|
||||
# - name: Archives
|
||||
# run: find artifacts -mindepth 1 -maxdepth 1 -exec tar -C {} -cvzf {}.tgz . \;
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
# with:
|
||||
# files: |
|
||||
# artifacts/*.tgz
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||
# create github release (which triggers the release workflows)
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||
|
||||
17
.github/workflows/cleanup.yml
vendored
17
.github/workflows/cleanup.yml
vendored
@@ -1,17 +0,0 @@
|
||||
name: cleanup
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '1 1 * * 1' # once a week clean out old artifacts
|
||||
|
||||
jobs:
|
||||
|
||||
expire:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Expire Artifacts
|
||||
uses: kolpav/purge-artifacts-action@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
expire-in: 1hour
|
||||
@@ -2,10 +2,10 @@ name: dockerhub
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
types: [ published ]
|
||||
|
||||
env:
|
||||
project: 'release-node'
|
||||
project: 'gun'
|
||||
|
||||
jobs:
|
||||
|
||||
@@ -26,10 +26,19 @@ jobs:
|
||||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
||||
|
||||
- name: Tag
|
||||
- name: Build
|
||||
run: |
|
||||
docker tag ${{ env.project }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.project }}:${GITHUB_REF/refs\/tags\/v/}
|
||||
docker tag ${{ env.project }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.project }}:latest
|
||||
echo "SHA=$GITHUB_SHA"
|
||||
docker build --build-arg \
|
||||
SHA=$GITHUB_SHA \
|
||||
BUILD_DATE=$(date +'%Y-%m-%d') \
|
||||
VCS_REF=${GITHUB_REF/refs\/tags\/v/} \
|
||||
VCS_URL=$GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} \
|
||||
VERSION=${GITHUB_REF/refs\/tags\/v/} \
|
||||
--label "sha=$GITHUB_SHA" \
|
||||
--tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.project }}:${GITHUB_REF/refs\/tags\/v/} \
|
||||
--tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.project }}:latest \
|
||||
.
|
||||
|
||||
- name: Push
|
||||
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.project }}
|
||||
@@ -2,7 +2,7 @@ name: npm
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
types: [ published ]
|
||||
|
||||
jobs:
|
||||
|
||||
Reference in New Issue
Block a user