Skip to content

Note: If you want to show deployments in PRs / pull requests, pass ref #29

@tony

Description

@tony

Want this?

image

Pass your branch name to ref ref: <your branch>

Looks like this:

name: CI

on:
  push:
    branches: [master]
  pull_request:

jobs:
  deployment:
    steps:
      - name: Get git output names
        id: git
        shell: bash
        run: |
          if [[ "${{ github.ref }}" != "refs/tags/"* ]]; then
            if [[ ${{ github.event_name }} == 'pull_request' ]]; then
              echo "::set-output name=current_branch::$HEAD_REF"
            else
              echo "::set-output name=current_branch::$REF_BRANCH"
            fi
          else
            REF=$(printf "%q" "${{ github.ref }}")
            REF_BRANCH=${REF/refs\/tags\/${{ inputs.strip_tag_prefix }}/}
            echo "::set-output name=current_branch::$(eval printf "%s" "$REF_BRANCH")"
          fi
  
      - uses: chrnorm/deployment-action@releases/v1
        name: Create GitHub deployment
        id: deployment
        with:
          token: "${{ github.token }}"
          target_url: http://my-app-url.com
          environment: production
          ref: ${{ steps.git.outputs.current_branch }}
  
      - name: Deploy my app
        run: |
          # add your deployment code here
  
      - name: Update deployment status (success)
        if: success()
        uses: chrnorm/deployment-status@releases/v1
        with:
          token: "${{ github.token }}"
          target_url: http://my-app-url.com
          state: "success"
          deployment_id: ${{ steps.deployment.outputs.deployment_id }}
          ref: ${{ steps.git.outputs.current_branch }}
  
      - name: Update deployment status (failure)
        if: failure()
        uses: chrnorm/deployment-status@releases/v1
        with:
          token: "${{ github.token }}"
          target_url: http://my-app-url.com
          state: "failure"
          deployment_id: ${{ steps.deployment.outputs.deployment_id }}
          ref: ${{ steps.git.outputs.current_branch }}

In practice, I used a fork with @jimCresswell's change at #26

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions