B4J Code Snippet GitHub Push (b4x_cba)

Read this if you dont know what b4x_cba is;


The latest version of b4x_cba introduces an action to push your project code to GitHub.

To get started you will need to

1. Get b4x_cba installed.
2. Create a repository on GitHub
3. Generate an API key (personal access token) on GitHub - I use a classic token

For more on GitHub access tokens see;

In your B4X project add your github config to your project attributes section. The below is from a B4J project. You only need to add; github_repository_owner, github_repository_name and github_branch (see example below)

B4X:
#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
  
    '###################################################################################
    ' GitHub Config for b4x_cba.exe
    ' You will be prompted for API key on first run
    ' API key is stored in same location as b4x_cba.exe
    ' .gitignore & .gitattribute files will automatically be created in project folder
    '###################################################################################
    'github_repository_owner=githubusername
    'github_repository_name=RepoName
    'github_branch=main

To call the action you can use an IDE link such as this;

B4X:
' Ctrl + click to push to GitHub: ide://run?File=b4x_cba.exe&Args=-action&Args=githubpush

Or if you wish to push everytime you make a Release build

B4X:
#CustomBuildAction: 2, b4x_cba.exe, -action githubpush

When the action is called for the first time you will be prompted for your API key. The API key is saved in same location as b4x_cba.exe in a file named "github_api_key.txt"

Notes on behaviour;

1. A .gitignore file will be created in the project folder. This will exclude folders like the Objects folder and the .meta file.
2. A .gitattributes file will be created in the project folder. This tells GitHub that your project is a B4X project (this uses @aerics format)
3. The repo must exist - you can do this on the GitHub website
4. The branch must exist - you can do this on the GitHub website
5. Only new or updated files will be uploaded
6. If there is a file on GitHub that is not in your project it will be deleted from GitHub (these are assumed to be orphans that have been removed from your project)
7. Local files are never deleted
 
Last edited:
Top