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.

on:
  push:
    branches:
    - main
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2.3.3
      - name: HubSpot Deploy Action
        uses: HubSpot/hubspot-cms-deploy-action@v1.4
        with:
          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
deploy:
#   which is run in the "deploy" stage
#     "deploy" stage is one of the pre-defined stages
#     docs: https://docs.gitlab.com/ee/ci/yaml/#stages
  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: https://docs.gitlab.com/ee/ci/yaml/index.html#onlyrefs--exceptrefs
  only:
    - 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: https://docs.gitlab.com/ee/ci/variables/
  environment:
    SRC_DIR: .
    DEST_DIR: climatepro_theme
    HUBSPOT_PORTAL_ID: 123456
    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: https://developers.hubspot.com/hs-search-results?term=gitlab
#   So yeah... we'll have to go raw with bash :}
  script:
#   We gonna be using their CLI ...
#     ... which is NodeJS-based so we install nodejs and yarn packages and the CLI itself
#     ref: https://developers.hubspot.com/docs/cms/developer-reference/local-development-cms-cli
#     We'll just replicate something similar to what they did in their GH action definition
#       ref: https://github.com/HubSpot/hubspot-cms-deploy-action/blob/main/action.yml
    - 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.

Cheers!

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

Can my code also be converted?

name: Release
on:
  push:
    tags:
      - 'v*'
  workflow_dispatch:

jobs:
  release:
    strategy:
      fail-fast: false
      matrix:
        platform: [macos-latest, ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.platform }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Node.js setup
        uses: actions/setup-node@v1
        with:
          node-version: 16

      - name: Rust setup
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable

      - name: Install dependencies (ubuntu only)
        if: matrix.platform == 'ubuntu-latest'
        run: |
          sudo apt-get update
          sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
      - name: Install app dependencies and build web
        run: yarn && yarn build

      - name: Build the app
        uses: tauri-apps/tauri-action@v0

        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tagName: v__VERSION__ # tauri-action replaces \_\_VERSION\_\_ with the app version
          releaseName: 'v__VERSION__'
          releaseBody: 'See the assets to download this version and install.'
          releaseDraft: true
          prerelease: false