From 284916f7e5da66102cbc30cc9b3105702a3671bf Mon Sep 17 00:00:00 2001 From: LoneRifle Date: Wed, 7 Aug 2024 10:13:21 +0800 Subject: [PATCH] build(ci): add publish to Docker Hub (#674) --- .github/workflows/npmpublish.yml | 24 ----------------- .github/workflows/publish.yml | 46 ++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 24 deletions(-) delete mode 100644 .github/workflows/npmpublish.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml deleted file mode 100644 index 36d2957..0000000 --- a/.github/workflows/npmpublish.yml +++ /dev/null @@ -1,24 +0,0 @@ -# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created -# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages - -name: Node.js Package - -on: - release: - types: [created] - -jobs: - publish-npm: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - with: - node-version: 'lts/*' - cache: 'npm' - cache-dependency-path: '**/package-lock.json' - registry-url: https://registry.npmjs.org/ - - run: npm ci - - run: npm publish --access public - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..b8965c5 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,46 @@ +name: Publish + +on: + release: + types: [created] + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 'lts/*' + cache: 'npm' + cache-dependency-path: '**/package-lock.json' + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + publish-docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 'lts/*' + cache: 'npm' + cache-dependency-path: '**/package-lock.json' + registry-url: https://registry.npmjs.org/ + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASS }} + - run: echo TAGNAME=`echo ${{ github.ref_name }} | sed 's/v//'` >> ${GITHUB_ENV} + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + tags: | + opengovsg/mockpass:latest + opengovsg/mockpass:${{ env.TAGNAME }}