<?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: Isaac Jandalala</title>
    <description>The latest articles on DEV Community by Isaac Jandalala (@isaac1m).</description>
    <link>https://dev.to/isaac1m</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%2F221903%2Fea23fa47-5d1f-48e4-b379-b3fc488bfa96.jpeg</url>
      <title>DEV Community: Isaac Jandalala</title>
      <link>https://dev.to/isaac1m</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/isaac1m"/>
    <language>en</language>
    <item>
      <title>Git Workflow Using GitHub Action (Part 1)</title>
      <dc:creator>Isaac Jandalala</dc:creator>
      <pubDate>Tue, 27 Jun 2023 10:44:32 +0000</pubDate>
      <link>https://dev.to/isaac1m/git-workflow-using-github-action-part-1-15ho</link>
      <guid>https://dev.to/isaac1m/git-workflow-using-github-action-part-1-15ho</guid>
      <description>&lt;h2&gt;
  
  
  Git Workflow
&lt;/h2&gt;

&lt;p&gt;This workflow follows a &lt;a href="https://www.atlassian.com/continuous-delivery/continuous-integration/trunk-based-development"&gt;trunk-based development&lt;/a&gt; paradigm. This is where small, frequent updates are merged to a core “trunk” or master branch.&lt;/p&gt;

&lt;p&gt;Aside from the master branch, we will also have a development branch and multiple feature branches.&lt;/p&gt;

&lt;p&gt;These branch types will be used as follows:&lt;/p&gt;

&lt;p&gt;Feature:  These will provide an isolated environment for every change to the codebase e.g. adding a new feature.&lt;/p&gt;

&lt;p&gt;Development: This is where all thoroughly reviewed and tested code from feature branches will be merged. This will contain pre-production code.&lt;/p&gt;

&lt;p&gt;Master branch: This will always have production-ready/working code merged from development.&lt;/p&gt;

&lt;p&gt;To merge changes from two branches, will use &lt;a href="https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests"&gt;pull requests&lt;/a&gt; (PRs).&lt;/p&gt;

&lt;p&gt;PRs should be thoroughly reviewed and tested before merging.&lt;/p&gt;

&lt;h3&gt;
  
  
  GitHub Actions
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.github.com/en/actions"&gt;GitHub actions&lt;/a&gt; will be used to run some automated tests whenever a new PR is merged into development and master.&lt;/p&gt;

&lt;p&gt;Later on, more automated tasks could be done using actions e.g. generating builds, deployment&lt;/p&gt;

&lt;h3&gt;
  
  
  Step By Step Example
&lt;/h3&gt;

&lt;p&gt;Add remote repository&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git remote add origin https://github.com/user/repo.git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In this case, the added repo is hosted on GitHub and (locally) named origin.&lt;/p&gt;

&lt;p&gt;Add the updated file to the staging area&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git add filename&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To add all files to the staging area use &lt;code&gt;git add .&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you want to add patches (i.e. specific sections of the file that have been changed) then run the command&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git add -p filename&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Commit the changes&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git commit -m "commit message here..."&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Use single quotes to add a multi-line commit message (although it is best to keep the messages brief).&lt;/p&gt;

&lt;p&gt;Push the new commits upstream, to a remote source (in this case, a repo on Github).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git push origin branch-name&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Running tests using GitHub actions&lt;/p&gt;

&lt;p&gt;GitHub Actions is a CI/CD platform for automating processes like build, test, and deployment. A workflow is defined and specifies jobs that are run whenever certain events are triggered e.g. running all tests whenever a new pull request is merged. Once a workflow is defined, it can be found under the “Actions” tab of the repository on GitHub.&lt;/p&gt;

&lt;p&gt;The example below defines a workflow that is using Go.&lt;br&gt;
&lt;/p&gt;

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

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:

  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3

    - name: Set up Go
      uses: actions/setup-go@v3
      with:
        go-version: 1.18

    - name: Build
      run: go build -v ./...

    - name: Test
      run: go test -v ./...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;on&lt;/code&gt; section defines the events that will trigger the jobs defined in the workflow to run. In this case, the workflow is listening for two events, namely:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;new commits pushed to the master branch. &lt;/li&gt;
&lt;li&gt;a pull request on the master branch.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;jobs&lt;/code&gt; section defines the jobs that’ll run when any of the events above occur. The first few steps under &lt;code&gt;build&lt;/code&gt; just specify the environment where the jobs are to be run. The final two steps will build the application and run all its defined tests. If any of the jobs fail (the build or any of the tests), the workflow run will have a failure status.&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>githubactions</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
