Workflow file for this run
This file contains hidden or 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: "Release" | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| build_script: | ||
| description: "Build script to be executed" | ||
| type: string | ||
| default: 'npm run build' | ||
| workspace: | ||
| description: "The default working directory on the runner for steps, and the default location of your repository when using the checkout action" | ||
| type: string | ||
| default: ${{ github.workspace }} | ||
| npm-publish: | ||
| description: "Determines if packages will be published to npm registry" | ||
| type: string | ||
| default: 'true' | ||
| node-version: | ||
| description: "NodeJS version" | ||
| type: string | ||
| default: "" | ||
| github-registry: | ||
| description: "Create .npmrc file for organization scoped Github Packages" | ||
| required: false | ||
| default: "true" | ||
| dockerize: | ||
| description: "Determines if docker image will be created" | ||
| type: string | ||
| default: 'true' | ||
| docker-platforms: | ||
| description: "Comma seperated target platforms for Docker images" | ||
| type: string | ||
| default: 'linux/amd64' | ||
| stage-repository: | ||
| description: "Git repository for stage files" | ||
| type: string | ||
| stage-repository-branch: | ||
| description: "Git repository for stage files" | ||
| type: string | ||
| default: 'main' | ||
| stage-files: | ||
| description: "<cr> delimited pairing of <Package name=Stage files>" | ||
| type: string | ||
| image-files: | ||
| description: "<cr> delimited pairing of <Package name=Image file name>" | ||
| type: string | ||
| secrets: | ||
| PERSONAL_ACCESS_TOKEN: | ||
| description: "Github personal access token" | ||
| required: true | ||
| NPM_TOKEN: | ||
| description: "Access token for npm.pkg.github.com repository" | ||
| required: false | ||
| DOCKERHUB_NAMESPACE: | ||
| description: "Dockerhub namespace. Required if 'stage-repository' defined" | ||
| required: false | ||
| DOCKERHUB_USERNAME: | ||
| description: "Dockerhub username. Required if 'dockerize' is set true" | ||
| required: false | ||
| DOCKERHUB_PASS: | ||
| description: "Dockerhub password. Required if 'dockerize' is set true" | ||
| required: false | ||
| jobs: | ||
| release: | ||
| name: "Release" | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| packages: ${{ steps.environment.outputs.packages }} | ||
| steps: | ||
| - name: "Setup Environment" | ||
| uses: panates/gh-setup-node@v1 | ||
| with: | ||
| token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
| fetch-depth: 100 | ||
| node-version: ${{ inputs.node-version }} | ||
| github-registry: ${{ inputs.github-registry }} | ||
| - name: "Scan Environment" | ||
| id: environment | ||
| uses: panates/gh-repository-info@v1 | ||
| with: | ||
| token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
| - name: "Check git tag" | ||
| run: | | ||
| if [ -z "${{ steps.environment.outputs.lastTag }}" ]; then | ||
| echo "Error: No git tag found." | ||
| exit 1 | ||
| fi | ||
| - name: "Build Changelog" | ||
| id: changelog | ||
| uses: panates/github-actions/.github/actions/node-build-changelog@v1 | ||
| with: | ||
| token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
| fromTag: ${{ steps.environment.outputs.prevSha }} | ||
| toTag: ${{ steps.environment.outputs.lastSha }} | ||
| - name: "Print changelog" | ||
| run: | | ||
| cat COMMIT_CHANGELOG.md | ||
| - name: "Build Packages" | ||
| shell: bash | ||
| run: | | ||
| ${{ inputs.build_script }} | ||
| - name: "Create GitHub Release" | ||
| id: create_release | ||
| uses: ncipollo/release-action@v1 | ||
| with: | ||
| token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
| tag: ${{ steps.environment.outputs.lastTag }} | ||
| bodyFile: "COMMIT_CHANGELOG.md" | ||
| draft: false | ||
| prerelease: false | ||
| replacesArtifacts: true | ||
| - name: "Publish Npm Packages" | ||
| if: ${{ steps.environment.outputs.npmPackages && inputs.npm-publish == 'true'}} | ||
| uses: panates/github-actions/.github/actions/release-npm@v1 | ||
| with: | ||
| token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
| npm-token: ${{ secrets.NPM_TOKEN }} | ||
| workspace: ${{ inputs.workspace }} | ||
| packages: ${{ steps.environment.outputs.packages }} | ||
| - name: "Build Docker Images" | ||
| if: ${{ steps.environment.outputs.dockerPackages && inputs.dockerize == 'true'}} | ||
| uses: panates/github-actions/.github/actions/release-docker@v1 | ||
| with: | ||
| token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
| workspace: ${{ inputs.workspace }} | ||
| packages: ${{ steps.environment.outputs.packages }} | ||
| platforms: ${{ inputs.docker-platforms }} | ||
| dockerhub-namespace: ${{ secrets.DOCKERHUB_NAMESPACE }} | ||
| docherhub-username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| docherhub-password: ${{ secrets.DOCKERHUB_PASS }} | ||
| image-files: ${{ inputs.image-files }} | ||
| stage_deploy: | ||
| if: ${{ inputs.stage-repository != '' }} | ||
| name: Stage Deploy | ||
| needs: release | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout manifest repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: ${{ inputs.stage-repository }} | ||
| token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
| ref: ${{ inputs.stage-repository-branch }} | ||
| - name: Update image in deployment yaml | ||
| uses: panates/github-actions/.github/actions/stage-deploy@v1 | ||
| with: | ||
| token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
| packages: ${{ needs.release.outputs.packages }} | ||
| dockerhub-namespace: ${{ secrets.DOCKERHUB_NAMESPACE }} | ||
| docherhub-username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| docherhub-password: ${{ secrets.DOCKERHUB_PASS }} | ||
| image-files: ${{ inputs.image-files }} | ||
| stage-files: ${{ inputs.stage-files }} | ||