HomeAboutPostsTagsProjectsRSS
┌─
ARTICLE
─┐

└─
─┘

Enabling APIs

To get started with setting up a CI/CD pipeline using Google Cloud Build and GitHub, the first step is to enable the necessary APIs in your Google Cloud Console. Specifically, you need to enable the Cloud Build API and the Cloud Run API. This can be done easily by navigating to the APIs & Services section in the Google Cloud Console and enabling the respective APIs.

Connecting GitHub Repository

Once the APIs are enabled, the next step is to connect your GitHub repository to Google Cloud Build. To do this, navigate to the Cloud Build dashboard in the Google Cloud Console. From there, go to the “Triggers” section and click on “Connect Repository”. Choose GitHub as the source and authenticate with your GitHub account. After authentication, select the repository you want to connect to Google Cloud Build.

Creating Build Trigger

After successfully connecting your GitHub repository, you need to create a build trigger. A build trigger defines the conditions under which a build should be triggered, such as when changes are pushed to a specific branch or tag. To create a build trigger, specify the branch or tag that should trigger the build and define the build configuration. The build configuration can be defined using a cloudbuild.yaml file in your repository. This file specifies the steps that should be performed during the build process.

Here’s a sample cloudbuild.yaml file that builds a Docker image and deploys it to Cloud Run:

steps:
- name: 'gcr.io/cloud-builders/docker'
  args: ['build', '-t', 'gcr.io/$PROJECT_ID/my-image', '.']
- name: 'gcr.io/cloud-builders/gcloud'
  args: ['run', 'deploy', 'my-service', '--image', 'gcr.io/$PROJECT_ID/my-image', '--platform', 'managed']

Make sure to customize this file according to your project’s specific needs, such as the image name, service name, and any additional build steps required.

Granting Permissions to Cloud Build Service Account

Finally, in order for Cloud Build to have the necessary permissions to access and deploy the service to Cloud Run, you need to grant the Cloud Build service account the “Cloud Run Admin” role. This role provides the necessary permissions for the build process to deploy the service to Cloud Run successfully.

By following these steps, you can set up a CI/CD pipeline with Google Cloud Build and GitHub, automating the build and deployment process whenever changes are pushed to your GitHub repository. This ensures a seamless and efficient development workflow, allowing you to focus on writing code and delivering your application quickly and reliably.

┌─
ARTICLE
─┐

└─
─┘

As of the time of writing, the current version of A-Shell is 1.12.1.

Passing Python Files to A-Shell

When using the iOS shortcut action A-Shell , the Put File action does not provide an option to specify the filename. Instead, it automatically names the file based on the first line of th content, excluding special symbols.

Base on this observation we can use the first line to specify filename and modify it after the file creation.

Let’s consider the following content.

getgif
import sys

if __name__ == "__main__":
    # print the first command line argument
    print(sys.argv[1])

it will be named getgif.txt after being passed from the “Text” action into A-Shell put file action

Removing the First Line with Sed

To remove the first line of a file (in this case, getgif.txt), we can utilize the Execute Command shortcut action in A-Shell. The command we can use is

sed -i '' '1d' getgif.txt

Executing the Python Script

Once we have removed the first line of the file, we can proceed to execute the Python script within A-Shell using Execute Command

python getgif.txt "hello"