Bump the npm-dependencies group with 27 updates #143
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: branch deploy | |
# The workflow to execute on is comments that are newly created | |
on: | |
issue_comment: | |
types: [ created ] | |
# Permissions needed for reacting and adding comments for IssueOps commands | |
permissions: | |
pull-requests: write | |
deployments: write | |
contents: write | |
checks: read | |
pages: write | |
id-token: write | |
# set an environment variable for use in the jobs pointing the site_url | |
env: | |
site_url: https://eltana.com | |
jobs: | |
# branch-deploy trigger job | |
trigger: | |
if: # only run on pull request comments and very specific comment body string as defined in our branch-deploy settings | |
${{ github.event.issue.pull_request && | |
(contains(github.event.comment.body, '.deploy') || | |
contains(github.event.comment.body, '.lock') || | |
contains(github.event.comment.body, '.wcid') || | |
contains(github.event.comment.body, '.unlock')) }} | |
runs-on: ubuntu-latest | |
outputs: # set outputs for use in downstream jobs | |
continue: ${{ steps.branch-deploy.outputs.continue }} | |
noop: ${{ steps.branch-deploy.outputs.noop }} | |
deployment_id: ${{ steps.branch-deploy.outputs.deployment_id }} | |
environment: ${{ steps.branch-deploy.outputs.environment }} | |
ref: ${{ steps.branch-deploy.outputs.ref }} | |
comment_id: ${{ steps.branch-deploy.outputs.comment_id }} | |
initial_reaction_id: ${{ steps.branch-deploy.outputs.initial_reaction_id }} | |
actor_handle: ${{ steps.branch-deploy.outputs.actor_handle }} | |
steps: | |
# execute the branch-deploy action | |
- uses: github/branch-deploy@v8 | |
id: branch-deploy | |
with: | |
trigger: ".deploy" | |
environment: "github-pages" | |
production_environments: "github-pages" | |
environment_targets: "github-pages" | |
skip_completing: "true" # we will complete the deployment manually in the 'result' job | |
admins: "GrantBirki" # <--- add your GitHub username here (if you want to use the admins feature) | |
# build the github-pages site with hugo | |
build: | |
needs: trigger | |
if: ${{ needs.trigger.outputs.continue == 'true' }} # only run if the trigger job set continue to true | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.trigger.outputs.ref }} | |
- name: astro build cache | |
id: astro-build-cache | |
uses: actions/cache@v3 | |
with: | |
path: .cache | |
key: ${{ runner.os }}-astro-build-${{ hashFiles('**/cache.json') }} | |
- name: build with astro | |
uses: withastro/action@f122c0232093b3504e4c841a46c2eebd07c47392 # pin@v1.0.3 | |
# deploy to GitHub Pages | |
deploy: | |
needs: [ trigger, build ] | |
if: ${{ needs.trigger.outputs.continue == 'true' }} # only run if the trigger job set continue to true | |
runs-on: ubuntu-latest | |
steps: | |
# deploy the site to GitHub Pages | |
- name: deploy | |
id: deployment | |
uses: actions/deploy-pages@de14547edc9944350dc0481aa5b7afb08e75f254 # pin@v2.0.5 | |
# update the deployment result - manually complete the deployment that was created by the branch-deploy action | |
result: | |
needs: [ trigger, build, deploy ] | |
runs-on: ubuntu-latest | |
# run even on failures but only if the trigger job set continue to true | |
if: ${{ always() && needs.trigger.outputs.continue == 'true' }} | |
steps: | |
# if a previous step failed, set a variable to use as the deployment status | |
- name: set deployment status | |
id: deploy-status | |
if: ${{ needs.trigger.result == 'failure' || needs.build.result == 'failure' || | |
needs.deploy.result == 'failure' }} | |
run: | | |
echo "DEPLOY_STATUS=failure" >> $GITHUB_OUTPUT | |
# use the GitHub CLI to update the deployment status that was initiated by the branch-deploy action | |
- name: Create a deployment status | |
env: | |
GH_REPO: ${{ github.repository }} | |
GH_TOKEN: ${{ github.token }} | |
DEPLOY_STATUS: ${{ steps.deploy-status.outputs.DEPLOY_STATUS }} | |
run: | | |
if [ -z "${DEPLOY_STATUS}" ]; then | |
DEPLOY_STATUS="success" | |
fi | |
gh api \ | |
--method POST \ | |
repos/{owner}/{repo}/deployments/${{ needs.trigger.outputs.deployment_id }}/statuses \ | |
-f environment='${{ needs.trigger.outputs.environment }}' \ | |
-f state=${DEPLOY_STATUS} | |
# use the GitHub CLI to remove the non-sticky lock that was created by the branch-deploy action | |
- name: Remove a non-sticky lock | |
env: | |
GH_REPO: ${{ github.repository }} | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh api \ | |
--method DELETE \ | |
repos/{owner}/{repo}/git/refs/heads/${{ needs.trigger.outputs.environment }}-branch-deploy-lock | |
# remove the default 'eyes' reaction from the comment that triggered the deployment | |
# this reaction is added by the branch-deploy action by default | |
- name: remove eyes reaction | |
env: | |
GH_REPO: ${{ github.repository }} | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh api \ | |
--method DELETE \ | |
repos/{owner}/{repo}/issues/comments/${{ needs.trigger.outputs.comment_id }}/reactions/${{ needs.trigger.outputs.initial_reaction_id }} | |
# if the deployment was successful, add a 'rocket' reaction to the comment that triggered the deployment | |
- name: rocket reaction | |
if: ${{ steps.deploy-status.outputs.DEPLOY_STATUS != 'failure' }} | |
uses: GrantBirki/comment@v2.0.8 | |
with: | |
comment-id: ${{ needs.trigger.outputs.comment_id }} | |
reactions: rocket | |
# if the deployment failed, add a '-1' (thumbs down) reaction to the comment that triggered the deployment | |
- name: failure reaction | |
if: ${{ steps.deploy-status.outputs.DEPLOY_STATUS == 'failure' }} | |
uses: GrantBirki/comment@v2.0.8 | |
with: | |
comment-id: ${{ needs.trigger.outputs.comment_id }} | |
reactions: "-1" | |
# if the deployment was successful, add a 'success' comment | |
- name: success comment | |
if: ${{ steps.deploy-status.outputs.DEPLOY_STATUS != 'failure' }} | |
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # pin@v3.1.0 | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
body: | | |
### Deployment Results ✅ | |
**${{ needs.trigger.outputs.actor_handle }}** successfully deployed branch `${{ needs.trigger.outputs.ref }}` to **${{ needs.trigger.outputs.environment }}** | |
> [View Live Deployment](${{ env.site_url }}) :link: | |
# if the deployment was not successful, add a 'failure' comment | |
- name: failure comment | |
if: ${{ steps.deploy-status.outputs.DEPLOY_STATUS == 'failure' }} | |
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # pin@v3.1.0 | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
body: | | |
### Deployment Results ❌ | |
**${{ needs.trigger.outputs.actor_handle }}** had a failure when deploying `${{ needs.trigger.outputs.ref }}` to **${{ needs.trigger.outputs.environment }}** |