Skip to content

Commit

Permalink
ci: use vault to read secret
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Yu <jack.yu@suse.com>
  • Loading branch information
Yu-Jack committed Apr 12, 2024
1 parent 9565f65 commit d529c8c
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions .github/workflows/template-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
jobs:
dapper-build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
container:
image: rancher/dapper:v0.5.8
strategy:
Expand All @@ -33,6 +36,8 @@ jobs:
arch=$(echo ${{ matrix.platform }} | cut -c 7-)
echo "ARCH=$arch" >> "$GITHUB_OUTPUT"

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

Expand All @@ -42,12 +47,20 @@ jobs:
- name: Run dapper
run: dapper ci

- name: Read some Secrets
uses: rancher-eio/read-vault-secrets@main
if: ${{ inputs.push == true }}
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD
- name: Login to Docker Hub
uses: docker/login-action@v3
if: ${{ inputs.push == true }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}

- name: Docker Build
uses: docker/build-push-action@v5
Expand All @@ -65,17 +78,27 @@ jobs:
manifest:
if: ${{ inputs.push == true }}
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
needs:
- dapper-build
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Read some Secrets
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.docker_username }}
password: ${{ secrets.docker_password }}
username: ${{ env.docker_username }}
password: ${{ env.docker_password }}

- name: Create Manifest arm64 and amd64
run: >
Expand Down

0 comments on commit d529c8c

Please sign in to comment.