diff --git a/go/build-and-test/action.yml b/go/build-and-test/action.yml index 76d4604..5d4f41f 100644 --- a/go/build-and-test/action.yml +++ b/go/build-and-test/action.yml @@ -55,18 +55,12 @@ runs: id: get-short-sha run: echo "short_sha=`echo ${GITHUB_SHA::7}`" > $GITHUB_OUTPUT shell: bash - - name: Configure Go environment - uses: wishabi/github-actions/go/configure@v0 + - name: Run custom Go build action + uses: wishabi/github-actions/go/build@skip-test with: FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} BUF_BUILD_USER: ${{ inputs.BUF_BUILD_USER }} BUF_BUILD_API_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} - - name: Setup Go dependencies - uses: wishabi/github-actions/go/deps@v0 - env: - BUF_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} - with: - FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} - name: Run custom Go test action uses: wishabi/github-actions/go/test@v0 env: diff --git a/go/build/action.yml b/go/build/action.yml new file mode 100644 index 0000000..363631d --- /dev/null +++ b/go/build/action.yml @@ -0,0 +1,119 @@ +name: "Go Build" +description: "Build go repo" + +inputs: + FLIPPCIRCLECIPULLER_REPO_TOKEN: + description: Flipp circleci repo token + required: true + BUF_BUILD_USER: + description: Buf CI user stored as secret + required: false + BUF_BUILD_API_TOKEN: + description: Buf API token stored as secret + required: false + SLACK_CHANNEL_ID: + description: The Slack channel ID(s) to send the data to + required: false + SLACK_BOT_TOKEN: + description: The Slack bot token to pass the data to + required: false + +runs: + using: "composite" + steps: + - name: Set branch variable + id: set-branch + shell: bash + run: | + if [ "${{ github.event_name }}" == "pull_request" ]; then + branch="${{ github.event.pull_request.head.ref }}" + else + branch="${{ github.ref }}" + branch="${branch#refs/heads/}" + fi + echo "branch=${branch}" >> $GITHUB_OUTPUT + - name: Get short sha + id: get-short-sha + run: echo "short_sha=`echo ${GITHUB_SHA::7}`" > $GITHUB_OUTPUT + shell: bash + - name: Configure Go environment + uses: wishabi/github-actions/go/configure@v0 + with: + FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} + BUF_BUILD_USER: ${{ inputs.BUF_BUILD_USER }} + BUF_BUILD_API_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} + - name: Setup Go dependencies + uses: wishabi/github-actions/go/deps@v0 + env: + BUF_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} + with: + FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} + - name: Notify slack channel on failure + if: failure() && inputs.SLACK_CHANNEL_ID != null && github.ref == 'refs/heads/main' + uses: slackapi/slack-github-action@v1.24.0 + env: + SLACK_BOT_TOKEN: ${{ inputs.SLACK_BOT_TOKEN }} + with: + channel-id: ${{ inputs.SLACK_CHANNEL_ID }} + payload: | + { + "text": "Go Build Failed", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Go Build Failed", + "emoji": true + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Repository*\n\n\n*${{ github.event_name == 'pull_request' && 'Pull Request' || 'Branch' }}*\n${{ github.event_name == 'pull_request' && format('<{0}|{1}>', github.event.pull_request.html_url, github.event.pull_request.title) || format('', github.repository, github.sha, steps.set-branch.outputs.branch)}}" + }, + "accessory": { + "type": "image", + "image_url": "https://emoji.slack-edge.com/T02AJQYGN/fail/d35657341d0b7dc4.png", + "alt_text": "error icon" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Version/Commit*" + }, + { + "type": "mrkdwn", + "text": "*Event*" + }, + { + "type": "mrkdwn", + "text": "${{ steps.get-short-sha.outputs.short_sha }}" + }, + { + "type": "mrkdwn", + "text": "${{ github.event_name }}" + } + ] + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "*Triggered By:* ${{ github.triggering_actor }}" + } + ] + } + ] + }