Skip to content
lock

GitHub Action

Setup netrc

v2 Latest version

Setup netrc

lock

Setup netrc

Append an entry to the netrc file

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Setup netrc

uses: extractions/netrc@v2

Learn more about this action in extractions/netrc

Choose a version

netrc action

build

This GitHub Action will append an entry to the ~/.netrc file for you. File owner and access permission checks are done before writing to the file.

Usage

Inputs

Name Required Description Type Default
machine yes Identifies a remote machine name string
username no The user name for the remote machine string ''
password no The password for the remote machine string ''

Basic example

Add the following to your workflow.

- uses: extractions/netrc@v1
  with:
    machine: some.private.domain.com
    username: ${{ secrets.USERNAME }}
    password: ${{ secrets.PASSWORD }}

Example use case

In the below example we have a Python project that needs to install packages from a private PyPI registry. We want to be able to check-in a requirements.txt that contains an extra index URL but we don't want to check-in the credentials

requirements.txt:

--extra-index-url https://pypi.private.domain.com

requests==2.23.0
private-package==2.8.3

.github/workflows/build.yaml:

on: [push]

name: build

jobs:
  check:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - uses: extractions/netrc@v1
        with:
          machine: pypi.private.domain.com
          username: ${{ secrets.PYPI_USERNAME }}
          password: ${{ secrets.PYPI_PASSWORD }}

      - uses: actions/setup-python@v2
        with:
          python-version: 3.8

      - run: pip install -r requirements.txt

      # tests follow...

License

Licensed under either of

at your option.