Converting GitHub Action to Gitlab CI/CD

We used to use GitHub for a good chunck of our repos, and have recently migrated over to GitLab.

I am stuck however on trying to setup a workflow for deployment.

For GitHub we just used the following to run on main push.

    - main
    runs-on: ubuntu-latest
      - name: Checkout
        uses: actions/checkout@v2.3.3
      - name: HubSpot Deploy Action
        uses: HubSpot/hubspot-cms-deploy-action@v1.4
          src_dir: .
          dest_dir: climatepro_theme
          portal_id: ${{ secrets.hubspot_portal_id }}
          personal_access_key: ${{ secrets.hubspot_personal_access_key }}

I’m hoping someone here might be able to point me how to convert this over for gitlab.

Aight so…

# create the job called deploy
#   which is run in the "deploy" stage
#     "deploy" stage is one of the pre-defined stages
#     docs:
  stage: deploy
#   uses the latest alpine CT image because that's what I like, it's lightweight, fast, simple
  image: alpine
#   only runs on push event on branch "main"
#     docs:
    - pushes
    - main
#   We'll define stuff in ENVs here, but you can always use the CI secrets. I'll just put them here so you get the idea
#     docs:
    SRC_DIR: .
    DEST_DIR: climatepro_theme
    HUBSPOT_PERSONAL_ACCESS_KEY: the-personall-access-key
#   Apparently HubSpot kinda trash because they have nothing for GitLab even tho it's a rather large platform :thonk:
#     ref:
#   So yeah... we'll have to go raw with bash :}
#   We gonna be using their CLI ...
#     ... which is NodeJS-based so we install nodejs and yarn packages and the CLI itself
#     ref:
#     We'll just replicate something similar to what they did in their GH action definition
#       ref:
    - apk add nodejs yarn
    - yarn global add @hubspot/cli
#   And now we deploy the thingy
    - hs upload "$SRC_DIR" "$DEST_DIR" --use-env

I have not tested this, so I guess just fork the repo, create a testing deployment on hubspot (or however that platform even works) and test it out.
Keep me posted if it worked just fine on the 1st try :smiley:

1 Like

This worked! Thank you so much.

I only had to make one edit, changed environment to variables, and everything processed as it should.


WHAAT? Amazing :tada:
I honestly thought there’ll be more issues :stuck_out_tongue: