<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Zach W. </title>
    <description>The latest articles on DEV Community by Zach W.  (@zach0811).</description>
    <link>https://dev.to/zach0811</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3219579%2F54f31743-49df-46fb-9e58-80b234c9a61c.jpeg</url>
      <title>DEV Community: Zach W. </title>
      <link>https://dev.to/zach0811</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zach0811"/>
    <language>en</language>
    <item>
      <title>Automating App Version Update With Github Actions and Slack</title>
      <dc:creator>Zach W. </dc:creator>
      <pubDate>Fri, 27 Jun 2025 18:25:17 +0000</pubDate>
      <link>https://dev.to/zach0811/automating-app-version-update-with-github-actions-and-slack-5h49</link>
      <guid>https://dev.to/zach0811/automating-app-version-update-with-github-actions-and-slack-5h49</guid>
      <description>&lt;p&gt;My goal was to utilize Github Actions and Slack to update the version of my app. I got this idea from a manual task at work that I thought should be automated. It's a small task, but presented a good opportunity to practice Github Actions, Slack, and Shell Scripts.&lt;/p&gt;

&lt;p&gt;The app from work which inspired this project consists of a component library (App1) and the actual app (App2).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;App2 contains multiple experiences which each contain a package.json file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The original tasks from work included:&lt;/strong&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make a change in App1&lt;/li&gt;
&lt;li&gt;Create a PR and merge &lt;/li&gt;
&lt;li&gt;Once the PR is merged, a Github Actions (GHA) pipeline is activated which publishes the new version of App1 to an artifact manager.&lt;/li&gt;
&lt;li&gt;A Slack message is sent notifying us of the new version&lt;/li&gt;
&lt;li&gt;In order to update App2 we must physically change the version number in each of App2's package.json files.&lt;/li&gt;
&lt;li&gt;Install all the dependencies for each subexperience and build the app.&lt;/li&gt;
&lt;li&gt;Create a PR&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once this PR is merged, our dev pipeline is kicked off. &lt;/p&gt;

&lt;p&gt;My goal was to automate the manual steps of this process which included:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When the new version from App1 was created, the Slack message would include a button to kick off a new GHA workflow.&lt;/li&gt;
&lt;li&gt;This workflow would update the sub-experience versions, build the app, create a PR, and alert the team via Slack that the PR is ready for review.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That was my basic goal for this project. Since this was just a POC, I didn't directly implement it in the original code. I decided to replicate the steps using separate personal repo's. &lt;/p&gt;

&lt;p&gt;Below are the steps I took, the obstacles I encountered, and what I learned from this process. This article doesn't every minute detail of the project but should give you a good picture of what I did.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Create Slack Channel With Webhook&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You will need to create a Slack channel with an incoming webhook in order to test the messages. You can create a webhook by going to your "Workplace Settings". Once you create the webhook you can replace that URL in below .sh scripts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Creating the Repos&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;This project required 2 individual repositories.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I created 2 Github repositories (both Next.js apps)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;(Repo1) Innovation-Week-Components: Simulating the component library&lt;/li&gt;
&lt;li&gt;(Repo2) Innovation-Week-App: Simulating the app&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;In Repo1 you will need to add the following files.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A GHA workflow file in &lt;code&gt;.github/workflows&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Create Release

on:
    pull_request:
        types:
            - closed
        branches:
            - main
        paths-ignore:
            - '**/*.md'

permissions:
  contents: write

jobs:
    build-app:
      name: Build App
      runs-on: ubuntu-latest

      steps:
        - name: Checkout code
          uses: actions/checkout@v3

        - name: Execute npm_build.sh
          run: |
            echo "BRANCH_NAME=$BRANCH_NAME" &amp;gt;&amp;gt; $GITHUB_ENV
            chmod +x .github/cicd/scripts/npm_build.sh
            .github/cicd/scripts/npm_build.sh

    create-release:
        name: Create Release
        runs-on: ubuntu-latest

        steps:
            - name: Checkout code
              uses: actions/checkout@v3

            - name: Get version from package.json
              id: get_version
              run: |
                VERSION=$(node -p "require('./package.json').version")
                echo "VERSION=$VERSION" &amp;gt;&amp;gt; $GITHUB_ENV

            - name: Debug version
              run: echo "Version is ${{ env.VERSION }}"

            - name: Create GitHub Release
              uses: actions/create-release@v1
              env:
                GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
              with:
                tag_name: v${{ env.VERSION }}
                release_name: Release v${{ env.VERSION }}
                body: |
                  New release of the app.
                draft: false
                prerelease: false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A .sh script to send the Slack message in &lt;code&gt;.github&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# #!/bin/bash

set -e

cd ../../..
echo "$(pwd)"

cd "$GITHUB_WORKSPACE"

MERGE_COMMIT="Newest Testing Commit!"

NEW_VERSION_NUMBER=$(jq -r '.version' package.json)
echo $NEW_VERSION_NUMBER

echo "Changed version to ${NEW_VERSION_NUMBER}"

GITHUB_ACTIONS_URL="https://github.com/your-username/your-repo-name/actions"

curl --location 'https://hooks.slack.com/services/your-customer-slack-channel' \
--header 'Content-type: application/json' \
--data '{
    "blocks": [
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "New version '"${NEW_VERSION_NUMBER}"' published successfully. To deploy to develop, please update the app by clicking here and starting the workflow :point_right: \n\n Here'\''s what was added:\n```

'"${MERGE_COMMIT}"'

```"
            },
            "accessory": {
                "type": "button",
                "text": {
                    "type": "plain_text",
                    "text": "Update App"
                },
                "url": "'"${GITHUB_ACTIONS_URL}"'",
                "action_id": "button"
            }
        }
    ]
}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;In Repo2 you will need add the following files.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A GHA file in &lt;code&gt;.github/workflows&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This workflows creates the new branch, updates the app version, and creates the PR.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Update UI and Create PR

on:
  workflow_dispatch:

jobs:
  build-and-pr:
    runs-on: [ubuntu-latest]

    steps:
      - name: Checkout code
        uses: actions/checkout@v3
        with:
          persist-credentials: false

      - name: Set up Git
        run: |
          git config --global user.email "your-email"
          git config --global user.name "your-name"

      - name: Create and publish new branch
        env:
          GH_PAT: ${{ secrets.GH_PAT }}
        run: |
          git config user.name "your-name"
          git config user.email "your-email"
          BRANCH_STRING="APP-0000-Version-Bump"
          git checkout -b $BRANCH_STRING
          git remote set-url origin https://x-access-token:${GH_PAT}@github.com/username/Innovation-Week-App.git
          git push --set-upstream origin $BRANCH_STRING
          echo "BRANCH_NAME=$BRANCH_STRING"

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: 22.12.0
          always-auth: true
          registry-url: npm-url

      - name: Update UI Versions
        env:
          NEW_TOKEN: ${{ secrets.GH_PAT}}
        run: |
          chmod +x .github/cicd/scripts/update_ui_version.sh
          .github/cicd/scripts/update_ui_version.sh
      - name: Commit changes
        run: |
          git add .
          git commit -m "APP-0000: Version-Bump"
      - name: Push branch
        env:
          GH_PAT: ${{ secrets.GH_PAT }}
        run: git push https://x-access-token:${GH_PAT}@github.com/username/Innovation-Week-App.git HEAD

      - name: Create pull request 
        env:
          GH_TOKEN: ${{ secrets.GH_PAT}}
        id: create_pr
        run: |
          PR_URL=$(gh pr create \
            --title "chore: Version Bump" \
            --body "Version Bump." \
            --base main \
            --head APP-0000-Version-Bump)
            echo "PR_URL=$PR_URL"
            echo "PR_URL=$PR_URL" &amp;gt;&amp;gt; $GITHUB_OUTPUT
      - name: Send Slack Notification
        env:
          NEW_TOKEN: ${{ secrets.GH_PAT}}
        run: |
          chmod +x .github/cicd/scripts/send_slack_message.sh
          .github/cicd/scripts/send_slack_message.sh "${{ steps.create_pr.outputs.PR_URL }}"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In &lt;code&gt;.github&lt;/code&gt;, a script to update the app version.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# !/bin/bash

set -e

tag=$(curl -H "Authorization: Bearer $NEW_TOKEN" https://api.github.com/repos/username/Innovation-Week-Components/releases/latest | jq -r '.tag_name')

NEW_VERSION="${tag#v}"
export NEW_VERSION

echo "$NEW_VERSION"

NEW_BRANCH="APP-0000-Version-Bump"
echo "New Branch: $NEW_BRANCH"

echo "Current directory: $(pwd)"

if [ -f "package.json" ]; then
    echo "Updating root package.json"
    jq --arg newVersion "$NEW_VERSION" \
       '.version = $newVersion' \
       "package.json" &amp;gt; "package.json.tmp" &amp;amp;&amp;amp; mv "package.json.tmp" "package.json"
fi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In &lt;code&gt;.github&lt;/code&gt;, a script to send the Slack message&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash

set -e
# source update_ui_version.sh
source "$(dirname "$0")/update_ui_version.sh"

tag=$(curl -H "Authorization: Bearer $NEW_TOKEN" https://api.github.com/repos/user-name/Innovation-Week-Components/releases/latest | jq -r '.tag_name')

NEW_VERSION="${tag#v}"

# Ensure PR_URL is provided
if [ -z "$1" ]; then
  echo "Usage: $0 &amp;lt;PR_URL&amp;gt;"
  exit 1
fi

PR_URL="$1"

echo "Sending Slack notification for PR: $PR_URL"
echo "New version: $NEW_VERSION"

curl --location 'https://hooks.slack.com/services/your-slack-app' \
  --header 'Content-Type: application/json' \
  --data '{
    "blocks": [
      {
        "type": "section",
        "text": {
          "type": "mrkdwn",
          "text": "A pull request has been created to update  the UI, version: '"${NEW_VERSION}"'.\nClick here to review the pull request. :point_right:"
        },
        "accessory": {
          "type": "button",
          "text": {
            "type": "plain_text",
            "text": "Review PR"
          },
          "url": "'"${PR_URL}"'",
          "action_id": "button"
        }
      }
    ]
  }'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Sending a Slack message after making a change&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make any change you would like in Repo1. &lt;/li&gt;
&lt;li&gt;Commit and push your change.&lt;/li&gt;
&lt;li&gt;Create a PR and merge.&lt;/li&gt;
&lt;li&gt;After the PR is merged, the GHA workflow from above will run a .sh script  that will create a new release and send the Slack message.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpd4egqingd7dhkga6o5z.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpd4egqingd7dhkga6o5z.jpg" alt="Slack message Indicating That The PR has been merged." width="800" height="239"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Make sure that your repo is private. If your repo is public, Slack will reset the webhook link and the message will fail.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;While interacting with my webhook I found it helpful to test the webhook call using Postman.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;During this step is where I encourted a problem that I couldn't solve. I wanted the button in the Slack message to trigger the GHA workflow in Repo2.&lt;/p&gt;

&lt;p&gt;I wasn't able to find a solution to meet my needs for this. It is possible but the solutions I found required creating a server to handle the API call. &lt;/p&gt;

&lt;p&gt;Instead of the button triggering the workflow, it just takes us to the workflow page in Repo2. From there we manually trigger the workflow. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: We click the button and are taken to the Repo2 GHA workflow page.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5x84qtsbevdlzq60nwd1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5x84qtsbevdlzq60nwd1.jpg" alt="Arrow pointing the workflow in Github actions" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: From the actions page, we click the "Run Workflow" dropdown followed by the "Run Workflow" button.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3x0y2ahggdn7sj1cjzcj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3x0y2ahggdn7sj1cjzcj.jpg" alt="Github Actions dropdown with workflow button" width="685" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: This workflow will create a new branch to update the app version, create the PR, and send a Slack message alerting us.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0b6clonug14pygch14hl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0b6clonug14pygch14hl.jpg" alt="Slack message prompting us to create a PR" width="800" height="139"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Step 7: After we merge the PR, Repo2's version should match Repo1's version.&lt;/strong&gt;}&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0k45ik8dpjmrtvzfg30.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0k45ik8dpjmrtvzfg30.jpg" alt="App version screenshot" width="699" height="273"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhj5bq4q1hn72kdkjyqds.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhj5bq4q1hn72kdkjyqds.jpg" alt="App version screenshot" width="725" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;...Github actions is hard. I found it difficult to efficiently test and debug my workflows. Despite this, GHA is a powerful tool. I will continue to experiment with GHA. It's amazing the resources we have to automate the boring tasks so we can focus on building and creating  products.  &lt;/p&gt;

&lt;p&gt;I'm happy I gave this a try. This project allowed me get more experience with tools that I don't touch that often. I'm also blown away with the extensive tools and features that Slack offers. &lt;/p&gt;

&lt;p&gt;I'm confident there are many improvements to be made in this project. If you have suggestions please comment. My goal from this project is to get better!&lt;/p&gt;

</description>
      <category>githubactions</category>
      <category>automation</category>
    </item>
    <item>
      <title>Does anyone know how to resize images when writing an article? Setting the width and height in the markdown is not working.</title>
      <dc:creator>Zach W. </dc:creator>
      <pubDate>Wed, 25 Jun 2025 13:24:07 +0000</pubDate>
      <link>https://dev.to/zach0811/does-anyone-know-how-to-resize-images-when-writing-an-article-setting-the-width-and-height-in-the-57ba</link>
      <guid>https://dev.to/zach0811/does-anyone-know-how-to-resize-images-when-writing-an-article-setting-the-width-and-height-in-the-57ba</guid>
      <description></description>
      <category>howto</category>
      <category>markdown</category>
      <category>writing</category>
    </item>
    <item>
      <title>Does anyone know how to resize images for articles? The below method is not working when I preview the article. &lt;img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x2u3r9eidsfql0zlwmh0.jpg" width="100" height="100" /&gt;</title>
      <dc:creator>Zach W. </dc:creator>
      <pubDate>Wed, 25 Jun 2025 13:20:49 +0000</pubDate>
      <link>https://dev.to/zach0811/does-anyone-know-how-to-resize-images-for-articles-the-below-method-is-not-working-when-i-40km</link>
      <guid>https://dev.to/zach0811/does-anyone-know-how-to-resize-images-for-articles-the-below-method-is-not-working-when-i-40km</guid>
      <description></description>
      <category>help</category>
      <category>howto</category>
      <category>html</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
