<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>GitHub Archives - Codersee blog- Kotlin on the backend</title>
	<atom:link href="https://blog.codersee.com/tag/github/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Kotlin &#38; Backend Tutorials - Learn Through Practice.</description>
	<lastBuildDate>Wed, 16 Apr 2025 04:49:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://blog.codersee.com/wp-content/uploads/2025/04/cropped-codersee_logo_circle_2-32x32.png</url>
	<title>GitHub Archives - Codersee blog- Kotlin on the backend</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How To Pass Data Between Workflows in GitHub Actions?</title>
		<link>https://blog.codersee.com/how-to-pass-data-between-workflows-in-github-actions/</link>
					<comments>https://blog.codersee.com/how-to-pass-data-between-workflows-in-github-actions/#comments</comments>
		
		<dc:creator><![CDATA[Piotr]]></dc:creator>
		<pubDate>Tue, 17 Oct 2023 05:43:36 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CICD]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[GitHub Actions]]></category>
		<category><![CDATA[GitHub Workflows]]></category>
		<guid isPermaLink="false">https://codersee.com/?p=9007722</guid>

					<description><![CDATA[<p>In this article, I will show you how to pass data between workflows in GitHub actions- from workflow A to B (triggered by workflow_run).</p>
<p>The post <a href="https://blog.codersee.com/how-to-pass-data-between-workflows-in-github-actions/">How To Pass Data Between Workflows in GitHub Actions?</a> appeared first on <a href="https://blog.codersee.com">Codersee blog- Kotlin on the backend</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this tutorial, we would like to see how to pass data between workflows in GitHub Actions. And to be even more specific- how can we pass the data from <code>workflow A</code> to <code>workflow B</code>, which is triggered using the <code>workflow_run</code> event. </p>



<p>But before we start, just a quick reminder that this is my second post in the series about GitHub Actions workflow. And if you would like to see the introduction, then check out my previous article and <a href="https://blog.codersee.com/how-to-create-github-actions-workflow/" target="_blank" rel="noreferrer noopener">learn how to create your first workflow</a>.</p>



<h2 class="wp-block-heading" id="h-video-tutorial">Video Tutorial</h2>



<p>If you prefer <strong>video content</strong>, then check out my video:</p>



<div style="text-align: center; width: 90%; margin-left: 5%;">
<a href="https://blog.codersee.com/how-to-pass-data-between-workflows-in-github-actions/"><img decoding="async" src="https://blog.codersee.com/wp-content/plugins/wp-youtube-lyte/lyteCache.php?origThumbUrl=%2F%2Fi.ytimg.com%2Fvi%2FGewZriF7HV8%2Fhqdefault.jpg" alt="YouTube Video"></a><br /><br /></p></div>



<p>If you find this content useful,<strong> please leave a subscription&nbsp;</strong> 😉</p>



<h2 class="wp-block-heading" id="h-trigger-workflow-on-workflow-run">Trigger Workflow On <code>workflow_run</code> </h2>



<p>Let&#8217;s assume that we would like to add a new workflow to our GitHub Actions, <code>workflow B</code>, which will trigger whenever <code>workflow A</code> <strong>completes successfully</strong>. We go to the <em>events</em> documentation and figure out that the <a href="https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run">workflow_run</a> will be the right choice. </p>



<p>So, for the following <code>workflow A</code>:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="yaml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">name: Workflow A

on:
  push:
    branches: [ "main" ]

jobs:
  some_job:  
    runs-on: ubuntu-latest
    steps:
      - name: Some Step 
        run: echo "Hello!"</pre>



<p>We pretty quickly came up with something, like this: </p>



<pre class="EnlighterJSRAW" data-enlighter-language="yaml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">name: Workflow B

on:
  workflow_run:
    workflows: ["Workflow A"]
    types:
      - completed

jobs:  
  run_on_workflow_a_success:
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    runs-on: ubuntu-latest
    steps:
      - name: Run on workflow A success
        run: echo "Workflow A completes successfully"</pre>



<p>Whenever the <code>workflow A</code> completes successfully, we simply print out a message to the output. </p>



<h2 class="wp-block-heading" id="h-problem-with-passing-data">Problem With Passing Data</h2>



<p>But life is not usually that simple and we pretty quickly realize that we need to find a way to pass the data between our GitHub workflows.</p>



<p>If we learned from my previous article or spent some time with the official documentation, we finally land on the contexts page and try to find the necessary information. </p>



<p>If are lucky enough and the data we need are present, we can simply access them with one line of code. </p>



<p>Just like we did previously:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="yaml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">github.event.workflow_run.conclusion</pre>



<p>As we can see, the above line accesses information about <em>conclusion </em>from the <code>github</code> context. </p>



<p>But what if we would like to <strong>access some custom data produced by the <code>workflow A</code> within the <code>workflow B</code>? </strong></p>



<p>Well- that&#8217;s the point where the story begins 🙂 </p>



<h2 class="wp-block-heading" id="h-pass-data-between-github-workflows-with-artifacts">Pass Data Between GitHub Workflows With Artifacts</h2>



<p>Unfortunately, at the moment when I am writing this article, there&#8217;s no such thing as a custom context or something similar where we could put the data and access them inside another (dependent) workflow. </p>



<p>Fortunately, we can bypass this limitation by producing artifacts. </p>



<p>Let&#8217;s update our <code>workflow A</code> first: </p>



<pre class="EnlighterJSRAW" data-enlighter-language="yaml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">name: Workflow A

on:
  push:
    branches: [ "main" ]

jobs:
  some_job:  
    runs-on: ubuntu-latest
    steps:
      - name: Some Step 
        run: echo "Hello!"

  job_producing_data:  
    runs-on: ubuntu-latest
    steps:
      - name: Some Step 
        run: |
            printf '{ 
              "prop_1": "Some value",  
              "prop_2": true
            }' >> context.json
      - uses: actions/upload-artifact@v3
        with:
          name: context.json
          path: ./</pre>



<p>With this solution, we produce a JSON file called <em>context.json</em>, which then we publish as an <a href="https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts" target="_blank" rel="noreferrer noopener">artifact</a>. </p>



<p>In simple words, GitHub <strong>artifacts</strong> are files (or collections of files), that we can produce during the workflow run and access later- from other workflows, through the API, or simply in the actions tab:</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="806" height="216" src="http://blog.codersee.com/wp-content/uploads/2023/10/github_action_produced_artifact.png" alt="Image presents a screenshot from GitHub actions workflow run with produced artifact." class="wp-image-9007740" srcset="https://blog.codersee.com/wp-content/uploads/2023/10/github_action_produced_artifact.png 806w, https://blog.codersee.com/wp-content/uploads/2023/10/github_action_produced_artifact-300x80.png 300w, https://blog.codersee.com/wp-content/uploads/2023/10/github_action_produced_artifact-768x206.png 768w" sizes="(max-width: 806px) 100vw, 806px" /></figure>



<p>Following, let&#8217;s update the <code>workflow B</code> to consume this file and access its data:</p>



<p> </p>



<pre class="EnlighterJSRAW" data-enlighter-language="yaml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">name: Workflow B

on:
  workflow_run:
    workflows: ["Workflow A"]
    types:
      - completed

jobs:  
  run_on_workflow_a_success:
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    runs-on: ubuntu-latest
    steps:
      - name: Run on workflow A success
        run: echo "Workflow A completes successfully"

  download_context_artifact:
    runs-on: ubuntu-latest
    steps:
      - name: 'Download artifact'
        uses: actions/github-script@v6
        with:
          script: |
            let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
               owner: context.repo.owner,
               repo: context.repo.repo,
               run_id: context.payload.workflow_run.id,
            });
            
            let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
              return artifact.name == "context.json"
            })[0];
            
            let download = await github.rest.actions.downloadArtifact({
               owner: context.repo.owner,
               repo: context.repo.repo,
               artifact_id: matchArtifact.id,
               archive_format: 'zip',
            });
            
            let fs = require('fs');
            fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/context.zip`, Buffer.from(download.data));
            
      - name: 'Unzip artifact'
        run: unzip context.zip

      - name: 'Return Parsed JSON'
        uses: actions/github-script@v6
        id: return-parsed-json
        with:
          script: |
            let fs = require('fs');
            let data = fs.readFileSync('./context.json');
            return JSON.parse(data);

    outputs:
      property_one: ${{fromJSON(steps.return-parsed-json.outputs.result).prop_1}}
      property_two: ${{fromJSON(steps.return-parsed-json.outputs.result).prop_2}}

  log_context_values:
    needs:
      - download_context_artifact
    runs-on: ubuntu-latest
    steps:
      - name: 'Log Context Values'
        run: |
          echo "${{ needs.download_context_artifact.outputs.property_one }}"
          echo "${{ needs.download_context_artifact.outputs.property_two }}"</pre>



<p>As we can see, we added two new jobs: <code>download_context_artifact</code> and <code>log_context_values</code>. </p>



<p>The first one is responsible for downloading the artifact (unfortunately <strong>GitHub API supports only zip files</strong> at the moment). We list all articles from the triggering flow (<code>workflow A</code>), match the one named <code>context.json</code> and download it. </p>



<p>Then, we unzip the file and parse its JSON content. </p>



<p>As the last thing in the first job, we produce two <strong>outputs</strong>.<strong> </strong>The output is nothing else than a map accessible in all <strong>downstream jobs dependent on this job</strong>. And to put it simply, in all jobs which point to this one using <strong><em>needs</em></strong>.</p>



<p>The interesting thing here is that in order to access the parsed json- <code>return JSON.parse(data)</code>&#8211; we need to use the <strong>&lt;step id&gt;.outputs.result</strong>.</p>



<p>The second job, <code>log_context_values</code>, simply prints out our values. </p>



<h2 class="wp-block-heading" id="h-summary">Summary</h2>



<p>And that&#8217;s all for this tutorial, in which we learned how to pass data between workflows in GitHub actions. </p>



<p>I hope you enjoyed this one and if you would like to share your feedback with me or ask about anything, then let me know in the <strong>comments section</strong>.</p>
<p>The post <a href="https://blog.codersee.com/how-to-pass-data-between-workflows-in-github-actions/">How To Pass Data Between Workflows in GitHub Actions?</a> appeared first on <a href="https://blog.codersee.com">Codersee blog- Kotlin on the backend</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.codersee.com/how-to-pass-data-between-workflows-in-github-actions/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>How To Create a GitHub Actions Workflow</title>
		<link>https://blog.codersee.com/how-to-create-github-actions-workflow/</link>
					<comments>https://blog.codersee.com/how-to-create-github-actions-workflow/#respond</comments>
		
		<dc:creator><![CDATA[Piotr]]></dc:creator>
		<pubDate>Tue, 10 Oct 2023 06:00:00 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CICD]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[GitHub Actions]]></category>
		<category><![CDATA[GitHub Workflows]]></category>
		<guid isPermaLink="false">https://codersee.com/?p=9007701</guid>

					<description><![CDATA[<p>In this quick tutorial, I will teach you how to create a GitHub Actions workflow and customize some basic settings.</p>
<p>The post <a href="https://blog.codersee.com/how-to-create-github-actions-workflow/">How To Create a GitHub Actions Workflow</a> appeared first on <a href="https://blog.codersee.com">Codersee blog- Kotlin on the backend</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this tutorial, I would like to show you <strong>how to set up a new GitHub Actions workflow</strong> and a few interesting things that will help you configure it in no time. </p>



<p>At the end of this tutorial, you will know precisely how to: </p>



<ul class="wp-block-list">
<li>navigate in GitHub actions and create new workflows,</li>



<li>trigger workflows manually,  </li>



<li>create a job that runs only when another job succeeds, </li>



<li>use GitHub context and access its data. </li>
</ul>



<h2 class="wp-block-heading" id="h-video-tutorial">Video Tutorial</h2>



<p>If you prefer <strong>video content</strong>, then check out my video:</p>



<div style="text-align: center; width: 90%; margin-left: 5%;">
<p>
<a href="https://blog.codersee.com/how-to-create-github-actions-workflow/"><img decoding="async" src="https://blog.codersee.com/wp-content/plugins/wp-youtube-lyte/lyteCache.php?origThumbUrl=%2F%2Fi.ytimg.com%2Fvi%2FG4-vCV6sIkA%2Fhqdefault.jpg" alt="YouTube Video"></a><br /><br />
</p></div>



<p>If you find this content useful,<strong> please leave a subscription&nbsp;</strong> 😉</p>



<h2 class="wp-block-heading" id="h-what-is-github-actions">What Is GitHub Actions? </h2>



<p><strong>GitHub Actions</strong> is nothing else than a CI/CD (continuous integration/continuous delivery) platform. </p>



<p>To put it simply, it is a platform, that allows us to automate builds, testing, deployments, and many other things related to the process in your company, or the project. </p>



<p>In practice, we define so-called <strong>workflows</strong>, which are triggered whenever some <strong>event</strong> happens in our repository. An event can be a merge to the main, a push to the remote branch, a deployment update, and plenty more. </p>



<p>Each workflow consists of <strong>jobs</strong> running inside their own machine runner and each job can have multiple <strong>steps</strong> responsible for performing an actual action, like code check, running a test, or creating a deployment.</p>



<p>Lastly, each workflow is nothing else than a YAML file placed within the <code>.github/workflows</code> directory.</p>



<h2 class="wp-block-heading" id="h-create-first-workflow">Create First Workflow</h2>



<p>With all of that said, let&#8217;s navigate to our GitHub repository and select the <em>actions</em> tab. Alternatively, you can do that with the following link: <a href="https://github.com/codersee-blog/{YOUR_REPO_NAME}/actions/new" target="_blank" rel="noreferrer noopener">https://github.com/codersee-blog/{YOUR_REPO_NAME}/actions/new</a>.</p>



<p>Nextly, let&#8217;s click the <em>configure<strong> </strong></em>button: </p>



<figure class="wp-block-image aligncenter size-large is-resized"><img decoding="async" width="1024" height="478" src="http://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_create_1-1024x478.png" alt="Image presents how to create a first GitHub Actions workflow." class="wp-image-9007702" style="width:840px;height:392px" srcset="https://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_create_1-1024x478.png 1024w, https://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_create_1-300x140.png 300w, https://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_create_1-768x359.png 768w, https://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_create_1.png 1182w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p> As a result, we should see the editor with the following code: </p>



<pre class="EnlighterJSRAW" data-enlighter-language="yaml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the "main" branch
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v3

      # Runs a single command using the runners shell
      - name: Run a one-line script
        run: echo Hello, world!

      # Runs a set of commands using the runners shell
      - name: Run a multi-line script
        run: |
          echo Add other actions to build,
          echo test, and deploy your project.</pre>



<p>So, let&#8217;s clean it up a bit to avoid distraction: </p>



<pre class="EnlighterJSRAW" data-enlighter-language="yaml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">name: CI

on:
  push:
    branches: [ "main" ]
  
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Run a one-line script
        run: echo Hello, world!

      - name: Run a multi-line script
        run: |
          echo Add other actions to build,
          echo test, and deploy your project.</pre>



<p>To sum up, we&#8217;ve defined a new GitHub Actions workflow, named <em>CI</em>, which will be triggered whenever we push a new commit to the <em>main </em>branch.</p>



<p>Our workflow consists of one job, <em>build</em>, which will be run on the <em>Ubuntu</em> runner. This job will invoke has two steps, which will be run one after another: </p>



<ul class="wp-block-list">
<li>firstly, it will print out a one-line script, </li>



<li>lastly, it will invoke the multiline script. </li>
</ul>



<p>Quite easy, isn&#8217;t it? </p>



<p>So with all of that done, let&#8217;s change the name of the file to <code>ci.yml</code> and let&#8217;s commit our changes to the <em>main</em> branch: </p>



<figure class="wp-block-image aligncenter size-full"><img decoding="async" width="597" height="618" src="http://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_commit_to_main.png" alt="Image presents a popup for merging to the main branch" class="wp-image-9007703" srcset="https://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_commit_to_main.png 597w, https://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_commit_to_main-290x300.png 290w" sizes="(max-width: 597px) 100vw, 597px" /></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" id="h-how-to-view-workflow-run">How To View Workflow Run? </h2>



<p>With all of that done, let&#8217;s see how we can see the result of our triggered workflow. </p>



<p>To do so, let&#8217;s navigate to the following URL: <a href="https://github.com/codersee-blog/{your-repo-name}/actions/workflows/ci.yml" target="_blank" rel="noreferrer noopener">https://github.com/codersee-blog/{your-repo-name}/actions/workflows/ci.yml</a>.</p>



<p>On this page, we should see that our workflow run has completed successfully:</p>



<figure class="wp-block-image aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="177" src="http://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_run_view-1024x177.png" alt="" class="wp-image-9007704" srcset="https://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_run_view-1024x177.png 1024w, https://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_run_view-300x52.png 300w, https://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_run_view-768x133.png 768w, https://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_run_view-1536x266.png 1536w, https://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_run_view.png 1572w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<p>As the next step, let&#8217;s click on the <code>build</code> job and let&#8217;s see the output:</p>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="487" height="685" src="http://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_run_build_output.png" alt="Image presents the output ot the workflow" class="wp-image-9007705" srcset="https://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_run_build_output.png 487w, https://blog.codersee.com/wp-content/uploads/2023/10/github_workflow_run_build_output-213x300.png 213w" sizes="auto, (max-width: 487px) 100vw, 487px" /></figure>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<p>Excellent! </p>



<p>Both our scripts run successfully and we can see the expected output. </p>



<h2 class="wp-block-heading" id="h-how-to-trigger-flow-manually">How To Trigger Flow Manually? </h2>



<p>At this point, you might be wondering if (and if yes, then how) we can manually trigger the flow. </p>



<p>Well, unfortunately, to do so, we must edit our YAML file a little: </p>



<pre class="EnlighterJSRAW" data-enlighter-language="yaml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">name: CI

on:
  push:
    branches: [ "main" ]
  workflow_dispatch:  
  
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Run a one-line script
        run: echo Hello, world!

      - name: Run a multi-line script
        run: |
          echo Add other actions to build,
          echo test, and deploy your project.</pre>



<p>As we can see, the only thing we need to add is the <code>workflow_dispatch</code>. </p>



<p>This event, allows us to trigger our workflow using the <em>GitHub API</em>, <em>GitHub CLI</em>, or <em>GitHub browser interface</em>:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="162" src="http://blog.codersee.com/wp-content/uploads/2023/10/manually_trigger_workflow-1024x162.png" alt="Image shows how to manually trigger the GitHub Actions workflow thanks to the workflow_dispatch event trigger" class="wp-image-9007706" srcset="https://blog.codersee.com/wp-content/uploads/2023/10/manually_trigger_workflow-1024x162.png 1024w, https://blog.codersee.com/wp-content/uploads/2023/10/manually_trigger_workflow-300x47.png 300w, https://blog.codersee.com/wp-content/uploads/2023/10/manually_trigger_workflow-768x121.png 768w, https://blog.codersee.com/wp-content/uploads/2023/10/manually_trigger_workflow-1536x242.png 1536w, https://blog.codersee.com/wp-content/uploads/2023/10/manually_trigger_workflow.png 1540w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" id="h-how-to-disable-the-workflow">How To Disable The Workflow? </h2>



<p>But can we disable the workflow without deleting the file? </p>



<p>Yes, we can. </p>



<p>We can do that simply by using the <em>Disable workflow</em> button from the workflow runs page: </p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="160" src="http://blog.codersee.com/wp-content/uploads/2023/10/disable_workflow_button-1024x160.png" alt="Image shows how to disable GitHub Actions workflow " class="wp-image-9007707" srcset="https://blog.codersee.com/wp-content/uploads/2023/10/disable_workflow_button-1024x160.png 1024w, https://blog.codersee.com/wp-content/uploads/2023/10/disable_workflow_button-300x47.png 300w, https://blog.codersee.com/wp-content/uploads/2023/10/disable_workflow_button-768x120.png 768w, https://blog.codersee.com/wp-content/uploads/2023/10/disable_workflow_button-1536x240.png 1536w, https://blog.codersee.com/wp-content/uploads/2023/10/disable_workflow_button.png 1547w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" id="h-contexts-and-debugging">Contexts And Debugging </h2>



<p>Wonderful. At this point, we already know the basics of workflows and navigation in GitHub Actions. </p>



<p>As the next step, let&#8217;s learn a bit more about <strong>contexts</strong>. </p>



<p><strong>Contexts</strong> allow us to access information about the workflow runs, variables, runner environments, jobs, and steps. If you are looking for commit sha, PR author, branch name, or maybe GitHub access token, then that&#8217;s the place you should check out.</p>



<p>For the full list of contexts with descriptions please take a look at the <a href="https://docs.github.com/en/actions/learn-github-actions/contexts" target="_blank" rel="noreferrer noopener">official documentation</a>.</p>



<p>But from my end, I wanted to show you a useful tip if you would like to debug anything:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="yaml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">name: CI

on:
  push:
    branches: [ "main" ]
  workflow_dispatch:  
  
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Run a one-line script
        run: echo Hello, world!

      - name: Run a multi-line script
        run: |
          echo Add other actions to build,
          echo test, and deploy your project.
  
      - name: Who initialized the flow? 
        run: echo "${{ github.actor }} initialized the flow."

      - name: Debug GitHub context
        run: |
            echo " ${{ toJSON(github) }}"</pre>



<p>As we can see, the third step &#8211; Who initialized the flow?- prints out the &#8220;actor&#8221; (or simply the account) that initialized the flow. </p>



<p>The fourth step- Debug GitHub context- prints out <code>github</code> context to the output. </p>



<p>The <code>toJson</code> function returns a pretty-print JSON representation of our value.</p>



<p>As a result, we should see the following:</p>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="707" height="630" src="http://blog.codersee.com/wp-content/uploads/2023/10/debug_workflow_result.png" alt="Image shows the result of the Debug GitHub context job." class="wp-image-9007708" srcset="https://blog.codersee.com/wp-content/uploads/2023/10/debug_workflow_result.png 707w, https://blog.codersee.com/wp-content/uploads/2023/10/debug_workflow_result-300x267.png 300w" sizes="auto, (max-width: 707px) 100vw, 707px" /></figure>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<p>Whatsoever, when debugging we don&#8217;t need to worry about exposing our secrets. </p>



<p>GitHub hides them by default. </p>



<h2 class="wp-block-heading" id="h-run-job-after-another-job-finishes-successfully">Run Job After Another Job Finishes Successfully</h2>



<p>Excellent! At this point, we learned quite a lot about the GitHub Actions workflows. </p>



<p>We know how to declare them, how to debug contexts, and how to navigate inside the GitHub world. </p>



<p>As the last thing for our first meeting, let&#8217;s learn how we can make one job dependent on the other.</p>



<p>To do so, let&#8217;s edit our YAML file once again:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="yaml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">name: CI

on:
  push:
    branches: [ "main" ]
  workflow_dispatch:  
  
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Run a one-line script
        run: echo Hello, world!

      - name: Run a multi-line script
        run: |
          echo Add other actions to build,
          echo test, and deploy your project.
  
  second_job:        
    needs: build
    runs-on: ubuntu-latest
    
    steps:
      - name: I run only when build succeeds
        run: echo Hi!</pre>



<p>As we can see, the only thing we need here is <code>needs: build</code>. </p>



<p>To be more specific, the <code>needs</code> instruction allows us to specify jobs that must be completed <strong>successfully</strong> before our job starts. </p>



<p>Of course, we can define multiple jobs using the array syntax: <code>needs: [job1, job2]</code>. </p>



<h2 class="wp-block-heading" id="h-summary">Summary</h2>



<p>And that&#8217;s all for this quick tutorial on how to create GitHub Actions workflows. </p>



<p>If you are interested in learning more about this topic, then I highly encourage you to check out <a href="https://docs.github.com/en/actions/quickstart" target="_blank" rel="noreferrer noopener nofollow">their documentation</a>. I&#8217;m pretty sure you will find there anything you need. </p>



<p>But if that&#8217;s not the case, then <strong>let me know in the comments section or by using the <a href="https://codersee.com/contact/" target="_blank" rel="noreferrer noopener">contact</a> form 🙂 </strong></p>
<p>The post <a href="https://blog.codersee.com/how-to-create-github-actions-workflow/">How To Create a GitHub Actions Workflow</a> appeared first on <a href="https://blog.codersee.com">Codersee blog- Kotlin on the backend</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.codersee.com/how-to-create-github-actions-workflow/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: blog.codersee.com @ 2026-02-27 03:25:31 by W3 Total Cache
-->