How to use Forge CLI in a CI environment?

Hi @sopel ,

Thanks for these references and in particular the blog post.

Regards,
Dugald

We’d gone back to v4.5.2 and then converted over to use FORGE_EMAIL and FORGE_API_TOKEN env variables instead of forge login as described in the getting started. This worked.

After the last few posts here I decided to try the latest cli version again and re-add the login using the token option but for me this still does not work and I get the following error:

Error: The CLI couldn’t securely store your login credentials in a local keychain. Ensure you have libsecret installed. If a local keychain is not available, use environment variables before trying again. See https://go.atlassian.com/dac/platform/forge/getting-started/#log-in-with-an-atlassian-api-token for more.

Simply removing the forge login and using the environment variables seems to work fine though so thats what we’re going with - and per the getting started docs that seems to be the prescribed way.

1 Like

Hi folks,

In response to this topic, a new article on continuous delivery has been created. The best place for comments on the guide is probably the topic it was announced in.

Regards,
Dugald

Adding an updated GH Actions workflow in case people run across this thread.

Uses node 18, caching, supports custom UI, error logging, and is hopefully written simply enough that it’s easy to understand.

name: Deploy to forge app to atlassian cloud site staging and prod environments on push

on:
  push:
    branches: [main, production]

jobs:
  build:
    runs-on: ubuntu-latest
    name: Build the source code for deployment
    steps:
      - uses: actions/checkout@main
      - name: Use Node.js 18.x
        uses: actions/setup-node@v4
        with:
          node-version: 18
          cache: 'npm'
          cache-dependency-path: |
            package-lock.json
            static/admin-page/package-lock.json
            static/jsm-portal/package-lock.json
      - run: npm ci
      - run: npm install -g @forge/cli@latest --no-optional
      - name: Build admin page
        run: |
          cd static/admin-page
          npm install
          npm run build
      - name: Build jsm portal page
        run: |
          cd static/jsm-portal
          npm install
          npm run build
      - name: disable analytics
        run: forge settings set usage-analytics false
      - name: Deploy to atlassian cloud site
        run: |
          branch=${{ github.ref }}
          if [ $branch == "refs/heads/main" ]
          then
            forge deploy -e staging
            forge install --upgrade --non-interactive --site abrega.atlassian.net -e staging -p jira
          elif [ $branch == "refs/heads/production" ]
          then
            forge deploy -e production
          fi
        env:
          FORGE_EMAIL: ${{ secrets.FORGE_EMAIL }}
          FORGE_API_TOKEN: ${{ secrets.FORGE_TOKEN }}
      - name: Archive npm failure logs
        uses: actions/upload-artifact@v2
        if: failure()
        with:
          name: npm-logs
          path: ~/.npm/_logs

2 Likes

Thank you, @BPB. Already spent quite a few github actions runs until I landed on a text that would lead me to this thread.

Thanks for posting the full workflow yml, it saved hours, I’m sure.