Add dotenv versions setup action to workflows #9
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 publish Moodle images to Artifactory | |
concurrency: | |
group: ${{ github.workflow }}-github.ref }} | |
cancel-in-progress: false | |
env: | |
APP: moodle | |
USER: ${{ github.actor }} | |
on: | |
workflow_call: | |
push: | |
branches: | |
- dev | |
#- test | |
#- prod | |
paths: | |
- 'Moodle.Dockerfile' | |
- '**/config/moodle/**' | |
#- '**/workflows/build-push-moodle-image.yml' | |
- '**/workflows/**' | |
- '**/**.env' | |
pull_request: | |
branches: | |
- dev | |
#- test | |
#- prod | |
paths: | |
- 'Moodle.Dockerfile' | |
- '**/config/moodle/**' | |
#- '**/workflows/build-push-moodle-image.yml' | |
- '**/workflows/**' | |
- '**/**.env' | |
jobs: | |
#Print variables for logging and debugging purposes | |
checkEnv: | |
name: 📋 Environment Check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check Env Vars | |
run: | | |
echo Building ${{ env.MOODLE_DEPLOYMENT_NAME }}:${{ env.OPENSHIFT_DEPLOY_PROJECT }}-${{ github.ref_name }} | |
# Build Images | |
build-images: | |
name: '🔨 Build Moodle image and push to Artifactory' | |
needs: [checkEnv] | |
runs-on: ubuntu-latest | |
if: ${{ needs.checkEnv.SKIP_BUILDS != 'YES' }} && (github.ref_name == 'dev' || github.ref_name == 'test' || github.ref_name == 'prod') | |
steps: | |
# Checkout the PR branch | |
- name: 📤 Checkout Target Branch | |
uses: actions/checkout@v2 | |
# Login to Artifactory | |
- name: 🔑 Login to Artifactory | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ secrets.ARTIFACTORY_URL }} | |
username: ${{ secrets.ARTIFACTORY_USER }} | |
password: ${{ secrets.ARTIFACTORY_PASSWORD }} | |
- name: Setup Env Vars | |
id: dotenv | |
uses: falti/dotenv-action@v1 | |
with: | |
path: example.versions.env | |
export-variables: true | |
keys-case: upper | |
- name: Setup Versions Env Vars | |
id: dotenv_versions | |
uses: falti/dotenv-action@v1 | |
with: | |
path: example.versions.env | |
export-variables: true | |
keys-case: upper | |
- name: 🛠️ Pull PHP base image | |
run: | | |
docker pull ${{env.PHP_IMAGE}} | |
docker tag ${{env.PHP_IMAGE}} ${{ secrets.ARTIFACTORY_URL }}/${{env.PHP_IMAGE}} | |
docker push ${{ secrets.ARTIFACTORY_URL }}/${{env.PHP_IMAGE}} | |
- name: 🛠️ Build Moodle Image and push to Artifactory | |
run: docker buildx build --tag ${{ secrets.ARTIFACTORY_URL }}/${{ env.MOODLE_DEPLOYMENT_NAME }}:${{ env.OPENSHIFT_DEPLOY_PROJECT }}-${{ github.ref_name }} --output=type=image,push=true --push -f ${{ env.MOODLE_DOCKER_FILE_PATH }} . | |