docs: clarify tag usage in build action #168
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: DS User Guide Builds | |
on: | |
workflow_dispatch: | |
inputs: | |
tag_custom: | |
description: 'A custom docker image tag. Use "next" to deploy to designsafeci-next.tacc.utexas.edu. Use "dev" (or, in the future, "pprd", to deploy to pprd.designsafe-ci.org).' | |
required: false | |
type: string | |
push: | |
branches: | |
- main | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- | |
name: Checkout repo | |
uses: actions/checkout@v3 | |
- | |
name: Get shortsha and branch name | |
id: vars | |
run: | | |
if [ -z "$EVENT_SHA" ]; then SHORT_SHA=${GITHUB_SHA::8}; else SHORT_SHA=${EVENT_SHA::8}; fi | |
echo ::set-output name=sha_short::${SHORT_SHA} | |
SHORT_REF=`git symbolic-ref --short HEAD | sed 's/[^[:alnum:]\.\_\-]/-/g'` | |
echo ::set-output name=ref_short::${SHORT_REF} | |
env: | |
EVENT_SHA: ${{ github.event.client_payload.sha }} | |
- name: Print vars | |
run: | | |
echo $SHORT_SHA | |
echo $SHORT_REF | |
env: | |
SHORT_SHA: ${{ steps.vars.outputs.sha_short }} | |
SHORT_REF: ${{ steps.vars.outputs.ref_short }} | |
- | |
name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- | |
name: Build and push | |
uses: docker/build-push-action@v3 | |
with: | |
push: true | |
tags: designsafeci/ds-user-guide:${{ inputs.tag_custom && inputs.tag_custom || 'latest' }},designsafeci/ds-user-guide:${{ steps.vars.outputs.sha_short }},designsafeci/ds-user-guide:${{ steps.vars.outputs.ref_short }} | |
- | |
name: Post build status in slack | |
id: slack | |
uses: slackapi/slack-github-action@v1.23.0 | |
with: | |
# This data can be any valid JSON from a previous step in the GitHub Action | |
payload: | | |
{ | |
"build_status": "${{ job.status }}" | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |