This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
Update README.md #28
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: push-pipeline | |
on: | |
push: | |
branches: | |
- master | |
- staging | |
tags: | |
- "*" | |
jobs: | |
get-envs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- shell: bash | |
run: | | |
echo export IMG_TAG=${GITHUB_SHA::6} >> env-vars | |
- name: Uploading envs | |
uses: actions/upload-artifact@v2 | |
with: | |
name: env_artifact | |
path: env-vars | |
docker-build-and-push: | |
runs-on: ubuntu-latest | |
needs: | |
- get-envs | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Downloading image artficate | |
uses: actions/download-artifact@v2 | |
with: | |
name: env_artifact | |
- name: Build docker image | |
shell: bash | |
run: | | |
source env-vars | |
branch=${GITHUB_REF#refs/*/} | |
if [ $branch == "master" ] | |
then | |
docker build . -f Dockerfile -t ${{ secrets.REPONAME }}/${{ secrets.IMAGE_NAME }}:${IMG_TAG} | |
elif [ $branch == "staging" ] | |
then | |
docker build . -f Dockerfile -t ${{ secrets.REPONAME }}/${{ secrets.STAGING_IMAGE_NAME }}:${branch}-${IMG_TAG} | |
fi | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Push docker image | |
shell: bash | |
run: | | |
branch=${GITHUB_REF#refs/*/} | |
source env-vars | |
if [ $branch == "master" ] | |
then | |
docker push ${{ secrets.REPONAME }}/${{ secrets.IMAGE_NAME }}:${IMG_TAG} | |
elif [ $branch == "staging" ] | |
then | |
docker push ${{ secrets.REPONAME }}/${{ secrets.STAGING_IMAGE_NAME }}:${branch}-${IMG_TAG} | |
fi |