-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e215386
commit bb691d1
Showing
25 changed files
with
2,680 additions
and
109 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,84 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
# GitHub recommends pinning actions to a commit SHA. | ||
# To get a newer version, you will need to update the SHA. | ||
# You can also reference a tag or branch, but the action may change without warning. | ||
|
||
name: Publish Docker image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
release: | ||
types: [ published ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
push_to_registry: | ||
name: Push Docker image to Docker Hub | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: jerryokafor/url-shortener | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- name: Setup gcloud Auth | ||
id: auth | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
credentials_json: ${{ secrets.GCP_SA_KEY }} | ||
|
||
- name: Setup gcloud CLI | ||
uses: google-github-actions/setup-gcloud@v2 | ||
with: | ||
project_id: ${{ secrets.GCP_PROJECT_ID }} | ||
|
||
# - name: Access gcloud CLI | ||
# run: | | ||
# gcloud auth configure-docker | ||
|
||
- name: SSH into VM | ||
id: compute-ssh | ||
uses: google-github-actions/ssh-compute@v1 | ||
with: | ||
instance_name: ${{ vars.GCP_INSTANCE_NAME }} | ||
zone: ${{ vars.GCP_INSTANCE_ZONE }} | ||
ssh_private_key: ${{ secrets.GCP_SSH_PRIVATE_KEY }} | ||
command: | | ||
cat /home/jerryhanksokafor/.env | ||
sudo docker ps | ||
# sudo docker run --name url-shortener --env-file /home/jerryhanksokafor/.env -p 8000:8000 jerryokafor/url-shortener | ||
|
||
# Example of using the output | ||
- name: Show result of SSH int Vm | ||
id: test | ||
run: |- | ||
echo '${{ steps.compute-ssh.outputs.stdout }}' | ||
echo '${{ steps.compute-ssh.outputs.stderr }}' | ||
## This workflow uses actions that are not certified by GitHub. | ||
## They are provided by a third-party and are governed by | ||
## separate terms of service, privacy policy, and support | ||
## documentation. | ||
# | ||
## GitHub recommends pinning actions to a commit SHA. | ||
## To get a newer version, you will need to update the SHA. | ||
## You can also reference a tag or branch, but the action may change without warning. | ||
# | ||
#name: Publish Docker image | ||
# | ||
#on: | ||
# push: | ||
# branches: | ||
# - main | ||
# release: | ||
# types: [ published ] | ||
# workflow_dispatch: | ||
# | ||
#jobs: | ||
# push_to_registry: | ||
# name: Push Docker image to Docker Hub | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Check out the repo | ||
# uses: actions/checkout@v4 | ||
# | ||
# - name: Set up Docker Buildx | ||
# uses: docker/setup-buildx-action@v3 | ||
# | ||
# - name: Log in to Docker Hub | ||
# uses: docker/login-action@v3 | ||
# with: | ||
# username: ${{ secrets.DOCKER_USERNAME }} | ||
# password: ${{ secrets.DOCKER_PASSWORD }} | ||
# | ||
# - name: Extract metadata (tags, labels) for Docker | ||
# id: meta | ||
# uses: docker/metadata-action@v5 | ||
# with: | ||
# images: jerryokafor/url-shortener | ||
# | ||
# - name: Build and push Docker image | ||
# uses: docker/build-push-action@v5 | ||
# with: | ||
# context: . | ||
# file: ./Dockerfile | ||
# push: true | ||
# tags: ${{ steps.meta.outputs.tags }} | ||
# labels: ${{ steps.meta.outputs.labels }} | ||
# | ||
# - name: Setup gcloud Auth | ||
# id: account | ||
# uses: google-github-actions/account@v2 | ||
# with: | ||
# credentials_json: ${{ secrets.GCP_SA_KEY }} | ||
# | ||
# - name: Setup gcloud CLI | ||
# uses: google-github-actions/setup-gcloud@v2 | ||
# with: | ||
# project_id: ${{ secrets.GCP_PROJECT_ID }} | ||
# | ||
# # - name: Access gcloud CLI | ||
# # run: | | ||
# # gcloud account configure-docker | ||
# | ||
# - name: SSH into VM | ||
# id: compute-ssh | ||
# uses: google-github-actions/ssh-compute@v1 | ||
# with: | ||
# instance_name: ${{ vars.GCP_INSTANCE_NAME }} | ||
# zone: ${{ vars.GCP_INSTANCE_ZONE }} | ||
# ssh_private_key: ${{ secrets.GCP_SSH_PRIVATE_KEY }} | ||
# command: | | ||
# cat /home/jerryhanksokafor/.env | ||
# sudo docker ps | ||
## sudo docker run --name url-shortener --env-file /home/jerryhanksokafor/.env -p 8000:8000 jerryokafor/url-shortener | ||
# | ||
# # Example of using the output | ||
# - name: Show result of SSH int Vm | ||
# id: test | ||
# run: |- | ||
# echo '${{ steps.compute-ssh.outputs.stdout }}' | ||
# echo '${{ steps.compute-ssh.outputs.stderr }}' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.