delete out #17
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 Image for test | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: hello | |
on: | |
push: | |
branches: [ master ] | |
release: | |
types: [ published ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Login to GitHub Packages | |
if: ${{ github.ref_type == 'branch' }} | |
run: echo "${{ secrets.SECRETS_GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin | |
- name: Get Short SHA | |
if: ${{ github.ref_type == 'branch' }} | |
run: | | |
SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-7) | |
echo "Short SHA: $SHORT_SHA" | |
- name: Build images | |
if: ${{ github.ref_type == 'branch' }} | |
run: make build ARGS="ghcr.io/${{ github.repository }}/" IMAGE_TAG="$SHORT_SHA" IMAGE_NAME=${{ env.IMAGE_NAME }} | |
- name: Push images to repository | |
if: ${{ github.ref_type == 'branch' }} | |
run: make push ARGS="ghcr.io/${{ github.repository }}/" IMAGE_TAG="$SHORT_SHA" IMAGE_NAME=${{ env.IMAGE_NAME }} | |
deploy_test: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Get Short SHA | |
run: echo "${GITHUB_SHA:0:7}" > short_sha.txt | |
- name: Deploy Test | |
uses: easingthemes/ssh-deploy@main | |
if: ${{ github.ref_type == 'branch' }} | |
env: | |
REMOTE_HOST: ${{ secrets.REMOTE_HOST_TEST }} | |
REMOTE_USER: ubuntu | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY_TEST }} | |
SHORT_SHA: $(echo $GITHUB_SHA | cut -c1-7) | |
SCRIPT_RUN: | | |
docker ps |grep ${{ env.IMAGE_NAME }} && docker stop ${{ env.IMAGE_NAME }} && docker rm ${{ env.IMAGE_NAME }} | |
docker login ghcr.io -u $GITHUB_ACTOR -p "${{ secrets.SECRETS_GITHUB_TOKEN }}" | |
docker run -d --name ${{ env.IMAGE_NAME }} ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}:${{ env.SHORT_SHA }} |