Skip to content
This repository has been archived by the owner on Jul 2, 2022. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Exercise 8 - Connect Your Project to SAP Continuous Integration and Delivery - GitHub Setup

In exercises 8 - 11, you will create a project in a public GitHub repository to which you'll store your source code, enable SAP Continuous Integration and Delivery, and configure and run a predefined continuous integration and delivery (CI/CD) pipeline that automatically tests, builds, and deploys your code changes.

In this exercise, you will create a GitHub repository for your project, connect your project to the repository, and push your app's code to it.

Exercise 8.0 - Preparations

If you skipped an exercise or more to get to this exercise, you need to obtain the code of the project as it should be at the end of the previous exercise. To do so, perform the following steps.

  1. Click here to access the branch (code-ex7-build-and-deploy) that contains the project and the instructions how to obtain the code.

  2. Follow the steps on this page.

  3. When completed, return to the current README.md.

Exercise 8.1 - Create a GitHub Repository

After completing these steps, you will have created a public GitHub repository to which you'll store the source code of your project.

For this exercise, you need to have a GitHub user.

  1. Open and sign in to GitHub.

  2. In the Repositories tab, choose New.

    Create GitHub Repo

  3. As Repository name, enter products-inventory. Don't select any of the Initialize this repository with... checkboxes.

  4. Choose Create repository.

    Create GitHub Repo

  5. Copy the HTTPS URL of your newly created GitHub repository.

    Copy GitHub URL

Exercise 8.2 - Create a Personal Access Token for GitHub

After completing these steps, you will have created a personal access token to authenticate against GitHub.

To create a personal access token, which you can use instead of a password, follow the steps described in Creating a personal access token.

Exercise 8.3 - Connect Your GitHub Repository with Your SAP Fiori Project

After completing these steps, you will have added your SAP Fiori project sources to your GitHub repository.

  1. In SAP Business Application Studio, open a new terminal, and navigate to your project's root folder, products-inventory. It is the default folder when opening a new terminal.

    Open Terminal

  2. Configure your GitHub user information. Enter your email address and user name. You can use the email address that you used to register your GitHub account:

    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"
    
  3. For some operations Git will need your credentials. Configure Git to ask your credentials only once, when you run the first Git operation that requires credentials.

    git config --global credential.helper 'cache --timeout=3600'
    

    Using the above configuration, Git stores your Git credentials in an ephemral storage. If you stop or restart the dev space or the timeout expires, you'll need to re-enter your credentials the next time a Git operations requires them.

    We chose to use this mode in this session, mainly due to its simplicity. There are other options to avoid inputtng your credentials repeatedly, such as ssh, .netrc, git config --global credential.helper store.

  4. Click Source Control to open the Git view.

    Open Terminal

  5. Click the + icon at the top-right of the Git view to initialize a local GitHub repository.

    Open Terminal

  6. Hover over the CHANGES title, and click the + icon to stage all changes.

    Open Terminal

    You'll see that the U (Updated) file decoration changed to A (Added to staging).

  7. Add the message Push project content to GitHub to the Message box, and press [CTRL] + [ENTER] or click the v icon, to commit.

    commit

    The Git view is cleared, and at the bottom of the view HEAD COMMIT is created.
    commited

  8. In the terminal, link the local git repository to the remote GitHub repository that you created in exercise 8.1.

    git remote add origin <remote GitHub repository url>
    

    Replace <remote GitHub repository url> with the repository URL from GitHub.

  9. In the terminal, change the project's branch name in the local repository to main.

    The local repository default name is master (You can see it on the left side of the Status Bar). Best practice is to use main.

    git branch -M main
    


    branch main

  10. In the terminal, push the commit with your project content to the remote GitHub repository:

git push -u origin main
  1. When prompted, enter your GitHub user name and for password use your personal access token.

Until the credentials timeout expires or dev space stop, you will not need to input your credentials.

Summary

You've created a repository for your project in GitHub and stored in it your app's source code.

Continue to - Exercise 9 - Connect Your Project to SAP Continuous Integration and Delivery Service - Setup the Service.