GitHub Secrets
Store sensitive data securely.
Setting Secrets
- Go to Repository → Settings → Secrets
- Click "New repository secret"
- Add name and value
Using Secrets
yaml
1steps:
2 - name: Deploy
3 env:
4 DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
5 DATABASE_URL: ${{ secrets.DATABASE_URL }}
6 run: ./deploy.shEnvironment Variables
yaml
1env:
2 RAILS_ENV: test
3
4jobs:
5 test:
6 env:
7 CI: true
8 steps:
9 - env:
10 NODE_ENV: test
11 run: npm testGitHub Context Variables
yaml
1steps:
2 - run: |
3 echo "Repo: ${{ github.repository }}"
4 echo "Branch: ${{ github.ref }}"
5 echo "SHA: ${{ github.sha }}"
6 echo "Actor: ${{ github.actor }}"Environment Protection
yaml
1jobs:
2 deploy:
3 environment: production # Requires approval
4 steps:
5 - run: ./deploy.shConfigure environments in Settings → Environments.
