<?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: Seyed Hossein Mirhosseini</title>
    <description>The latest articles on DEV Community by Seyed Hossein Mirhosseini (@hosseinmirhosseini76).</description>
    <link>https://dev.to/hosseinmirhosseini76</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%2F887254%2F8ba5d0c7-0c3d-4e91-9e9e-49a056a37728.jpg</url>
      <title>DEV Community: Seyed Hossein Mirhosseini</title>
      <link>https://dev.to/hosseinmirhosseini76</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hosseinmirhosseini76"/>
    <language>en</language>
    <item>
      <title>Deploying Nuxt.js app to GitHub pages</title>
      <dc:creator>Seyed Hossein Mirhosseini</dc:creator>
      <pubDate>Wed, 27 Nov 2024 20:29:21 +0000</pubDate>
      <link>https://dev.to/hosseinmirhosseini76/deploying-nuxtjs-app-to-github-pages-27mj</link>
      <guid>https://dev.to/hosseinmirhosseini76/deploying-nuxtjs-app-to-github-pages-27mj</guid>
      <description>&lt;p&gt;In this brief tutorial, I'll guide you through the process of deploying your project on GitHub Pages. I'm assuming that your project is complete and ready for deployment.&lt;br&gt;
Now, let's follow these instructions step by step:&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Creating your Repository
&lt;/h2&gt;

&lt;p&gt;To start, create a new public repository on GitHub. If you already have one, feel free to skip this step.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Connect your repo with your app
&lt;/h2&gt;

&lt;p&gt;You can use commands below for this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote add origin https://github.com/{username}/{your_repo_name}.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then create a branch and name it to &lt;code&gt;main&lt;/code&gt; by this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git branch -M main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this step, you have to push your code on GitHub. Maybe need this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push --set-upstream origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Create your Action And Deploy it
&lt;/h2&gt;

&lt;p&gt;In this step you should go to the &lt;code&gt;Settings&lt;/code&gt; tab and then &lt;code&gt;Pages&lt;/code&gt; section.&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%2Fcaulnbqyvxpgw76ld069.png" 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%2Fcaulnbqyvxpgw76ld069.png" alt="GitHub pages setting section" width="800" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, in the &lt;code&gt;Branch&lt;/code&gt; section, select the &lt;code&gt;main&lt;/code&gt; branch and click the save button next to it.&lt;/p&gt;

&lt;p&gt;After that, the page reload and in &lt;code&gt;Build and deployment&lt;/code&gt; section you should open the menu in the &lt;code&gt;Source&lt;/code&gt; section and choose &lt;code&gt;GitHub Actions&lt;/code&gt; option.&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%2Fepfss658kbcnkrfxw50l.png" 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%2Fepfss658kbcnkrfxw50l.png" alt="Build and deployment Section" width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you see that GitHub make a URL for your repo that you can see the content in there, but we still have some work to do.&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%2Fm09kkkp639kv0ond3iep.png" 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%2Fm09kkkp639kv0ond3iep.png" alt="Config your workflow" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should now see a display similar to this. In this section, you can set up your deployment process using GitHub Action workflows. As shown in the image, GitHub typically identifies your repository workflow automatically. If it doesn't, don't worry, there's an easier way to manage it.&lt;br&gt;
Now you should click on the &lt;code&gt;Configure&lt;/code&gt; button as you see above. Then copy the below content and paste it in the editor you can see in the next page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# https://github.com/actions/deploy-pages#usage
name: Deploy to GitHub Pages
on:
  workflow_dispatch:
  push:
    branches:
      - main
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: corepack enable
      - uses: actions/setup-node@v4
        with:
          node-version: "20"
      # Pick your own package manager and build script
      - run: npm install
      - run: npx nuxt build --preset github_pages
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: ./.output/public
  # Deployment job
  deploy:
    # Add a dependency to the build job
    needs: build
    # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
    permissions:
      pages: write      # to deploy to Pages
      id-token: write   # to verify the deployment originates from an appropriate source
    # Deploy to the github_pages environment
    environment:
      name: github_pages
      url: ${{ steps.deployment.outputs.page_url }}
    # Specify runner + deployment step
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now almost done, you should click on the &lt;code&gt;Commit changes...&lt;/code&gt; button and commit your changes.&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%2Fgrtsue5hjnc5mpw9ma3s.png" 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%2Fgrtsue5hjnc5mpw9ma3s.png" alt="GitHub workflow editor" width="800" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the pop-up windows, you have the option to include additional content for your commit. If you choose not to, there's no negative consequence.&lt;/p&gt;

&lt;p&gt;Once you've committed your changes, navigate to the &lt;code&gt;Actions&lt;/code&gt; tab. There, you'll see an indication that your workflow has begun its job. You will need to wait for it to complete:&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%2Fq0ti0u3niyz2amiveebs.png" 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%2Fq0ti0u3niyz2amiveebs.png" alt="GitHub workflow section" width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After a few minutes, the yellow flag next to your workflow name will change to green, indicating everything has been successfully completed.&lt;/p&gt;

&lt;p&gt;Then, if you click on the name of your workflow, you can see this:&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%2F24oaz5n35derk9440c96.png" 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%2F24oaz5n35derk9440c96.png" alt="Workflow details" width="800" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you click the link generated by GitHub, you'll be able to see the results. To me, the outcome is as follows:&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%2F6qw08ieu7xtdxtl0g6yh.png" 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%2F6qw08ieu7xtdxtl0g6yh.png" alt="Deployment result" width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations, you did it👏.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Updating your project
&lt;/h2&gt;

&lt;p&gt;To make changes to your project, such as adding a section to a page, simply commit your modifications and push them to GitHub, it manages other stuff with your workflow that we add it earlier.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After pushing your changes and go to your GitHub page, you see something like this:&lt;/li&gt;
&lt;/ul&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%2F7nn050jo5cnvowsoj8pf.png" 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%2F7nn050jo5cnvowsoj8pf.png" alt="Your GitHub page" width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After a couple of minutes of waiting, the yellow sign turns green, and then your page has been successfully updated!. For me turn in to this:&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%2F720pwi7zknb1n9bplp8h.png" 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%2F720pwi7zknb1n9bplp8h.png" alt="Updated deployment result" width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusions
&lt;/h2&gt;

&lt;p&gt;You have now learned how to automatically deploy your Nuxt.js app using the GitHub Pages workflow system, and you understand how to update it with ease.&lt;/p&gt;




&lt;p&gt;I am thrilled to explore my website &lt;a href="https://hosseinmirhosseini76.github.io/" rel="noopener noreferrer"&gt;hosseinmirhosseini76.github.io&lt;/a&gt;😊👋&lt;/p&gt;

</description>
      <category>nuxt</category>
      <category>vue</category>
      <category>github</category>
      <category>git</category>
    </item>
  </channel>
</rss>
