This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and push to Github container registry | |
on: | |
push: | |
branches: ['main'] | |
pull_request: | |
branches: ['main'] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout to the repository | |
uses: actions/checkout@v3 | |
- name: Install ssh key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
name: github-actions | |
key: ${{ secrets.SSH_HEXCORE_KEY }} | |
known_hosts: 'just-a-placeholder-so-we-dont-get-errors' | |
config: | # will be appended to existing .ssh/config | |
Host target | |
HostName ${{ secrets.SSH_HOST }} | |
User ${{ secrets.SSH_USER }} | |
IdentityFile ~/.ssh/github-actions | |
Port 22 | |
- name: Adding Known Hosts | |
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts | |
- name: Copy to the remoye server using rsync | |
run: | | |
rsync -avzr --delete -e "ssh -p 22" . ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:~/temp/ | |
# - name: Set up NodeJS environment | |
# uses: actions/setup-node@v2 | |
# with: | |
# # Reads the node version from the .nvmrc file itself | |
# # node-version-file: '.nvmrc' | |
# # The node version can be hard-coded | |
# cache: 'yarn' | |
# cache-dependency-path: client/yarn.lock | |
# node-version: 16 | |
# - name: Install client`s package dependencies | |
# working-directory: ./client | |
# run: yarn install | |
# - name: Create client`s test build | |
# working-directory: ./client | |
# run: yarn build | |
# # Run test cases and this could ensure minimum coverage as well if set | |
# - name: Execute client`s test cases | |
# working-directory: ./client | |
# run: yarn test | |
# - name: Build image and save it as tar | |
# run: | | |
# docker build . -t piekerp:latest | |
# docker save -o piekerp-latest.tar piekerp:latest | |
# - name: Send tar image to the prod host machine using rsync | |
# uses: burnett01/[email protected] | |
# with: | |
# switches: -avzr --delete | |
# remote_path: ~/temp/ | |
# remote_host: ${{ secrets.SSH_HOST }} | |
# remote_user: ${{ secrets.SSH_USER }} | |
# remote_key: ${{ secrets.SSH_HEXCORE_KEY }} | |
# - name: Login to Github container registry | |
# uses: docker/login-action@v2 | |
# with: | |
# registry: ghcr.io | |
# username: ${{ github.actor }} | |
# password: ${{ secrets.CR_TOKEN }} | |
# - name: Push image to Github container registry | |
# uses: docker/build-push-action@v2 | |
# with: | |
# context: . | |
# file: ./Dockerfile | |
# push: true | |
# tags: ghcr.io/${{ github.repository }}:latest |