Skip to content

Instantly share code, notes, and snippets.

@ogawatti
Created November 26, 2022 14:03
Show Gist options
  • Save ogawatti/dfd0eaa31842a972ea89f70034b182fa to your computer and use it in GitHub Desktop.
Save ogawatti/dfd0eaa31842a972ea89f70034b182fa to your computer and use it in GitHub Desktop.
docker/build-push-action ssh and github secrets private key
---
name: build
on:
workflow_dispatch:
push:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set ENV for docker build
env:
TOKEN: ${{ secrets.TOKEN }}
run: |
mkdir -p ~/.ssh
echo "$TOKEN" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV
- uses: docker/build-push-action@v3
with:
push: false
tags: ogwatti/wattitest:latest
ssh: default
# syntax = docker/dockerfile:1.0-experimental
FROM node:16-bullseye-slim
ARG ssh_prv_key
RUN apt update \
&& apt upgrade -y \
&& apt install -y git
WORKDIR /app
COPY . .
RUN mkdir -p /root/.ssh && \
chmod 600 /root/.ssh && \
ssh-keyscan github.com > /root/.ssh/known_hosts
RUN --mount=type=ssh git clone git@github.com:ogawatti/wattitest-private-repo.git
RUN cat wattitest-private-repo/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment