Skip to content

Latest commit

 

History

History
65 lines (59 loc) · 2.43 KB

github-actions.md

File metadata and controls

65 lines (59 loc) · 2.43 KB

GitHub Actions

To build your container images with Github Actions, you have two different options, you can use the preinstalled software provided by the hosted runners or you can go with a container based job using one of the provided custom builder images:

Example with Docker:

jobs:
  build-with-docker-engine:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Login to DockerHub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - uses: actions/setup-node@v3
        with:
          cache: 'npm'
          node-version-file: '.nvmrc'
      - name: 'Install Dependencies'
        run: npm install
      - name: Derive appropriate SHAs for base and head for `nx affected` commands
        uses: nrwl/nx-set-shas@v3
      - name: 'Build images'
        run: INPUT_GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=container --parallel=2

Example with Podman:

jobs:
  build-with-podman-engine:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Login to DockerHub
        run: echo "$DOCKERHUB_TOKEN" | podman login -u $DOCKERHUB_USERNAME --password-stdin
        env:
          DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
          DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_TOKEN }}
      - uses: actions/setup-node@v3
        with:
          cache: 'npm'
          node-version-file: '.nvmrc'
      - name: 'Install Dependencies'
        run: npm install
      - name: Derive appropriate SHAs for base and head for `nx affected` commands
        uses: nrwl/nx-set-shas@v3
      - name: 'Build images'
        run: npx nx affected --base=$NX_BASE --head=$NX_HEAD --target=container --parallel=2