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.
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.
-
Click here to access the branch (
code-ex7-build-and-deploy
) that contains the project and the instructions how to obtain the code. -
Follow the steps on this page.
-
When completed, return to the current README.md.
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.
-
Open and sign in to GitHub.
-
As Repository name, enter products-inventory. Don't select any of the Initialize this repository with... checkboxes.
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.
After completing these steps, you will have added your SAP Fiori project sources to your GitHub repository.
-
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. -
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"
-
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
. -
Click the
+
icon at the top-right of the Git view to initialize a local GitHub repository. -
Hover over the
CHANGES
title, and click the+
icon to stage all changes.You'll see that the
U
(Updated) file decoration changed toA
(Added to staging). -
Add the message Push project content to GitHub to the Message box, and press [CTRL] + [ENTER] or click the
v
icon, to commit.The Git view is cleared, and at the bottom of the view
HEAD COMMIT
is created. -
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. -
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 usemain
.git branch -M main
-
In the terminal, push the commit with your project content to the remote GitHub repository:
git push -u origin main
- 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.
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.