Merge pull request #97 from atlanhq/m4380 #148
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: npm-publish | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
npm-publish: | |
name: npm-publish | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@master | |
- name: Set up Node.js | |
uses: actions/setup-node@master | |
with: | |
node-version: 20.9.0 | |
- name: Publish if version has been updated | |
uses: pascalgn/[email protected] | |
with: # All of theses inputs are optional | |
tag_name: "v%s" | |
tag_message: "v%s" | |
commit_pattern: "^Release (\\S+)" | |
workspace: "." | |
env: # More info about the environment variables in the README | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated | |
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings | |
- uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: Get published version | |
id: get_version | |
run: | | |
ARGOPM_VERSION=$(npm show . version) | |
echo "The published version is: $ARGOPM_VERSION" | |
echo "::set-output name=argopm_version::$ARGOPM_VERSION" | |
# sleep 5 sec to make sure we can install the latest published version from npm in Dockerfile | |
sleep 5 | |
- name: 'Get Previous tag' | |
id: previoustag | |
uses: "WyriHaximus/github-action-get-previous-tag@master" | |
- run: echo "REPOSITORY_NAME=`echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//"`" >> $GITHUB_ENV | |
shell: bash | |
- name: Set up Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to GitHub Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: $GITHUB_ACTOR | |
password: ${{ secrets.ORG_PAT_GITHUB }} | |
- name: Build and push docker image | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: | | |
ghcr.io/atlanhq/${{ github.event.repository.name }}:latest | |
ghcr.io/atlanhq/${{ github.event.repository.name }}:${{ steps.previoustag.outputs.tag }} | |
build-args: | | |
ACCESS_TOKEN_USR=$GITHUB_ACTOR | |
ACCESS_TOKEN_PWD=${{ secrets.ORG_PAT_GITHUB }} | |
ARGOPM_VERSION=${{ steps.get_version.outputs.published_version }} |