Skip to content

Update snapshot & prod compose for web #1232

Update snapshot & prod compose for web

Update snapshot & prod compose for web #1232

Workflow file for this run

# Continuous Integration
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
pre-check:
name: Pre-Check
continue-on-error: true
runs-on: ubuntu-latest
outputs:
images: ${{ steps.map-images.outputs.result }}
steps:
- name: Check for skippable jobs
id: skip-check
uses: fkirc/skip-duplicate-actions@v5
continue-on-error: true
with:
cancel_others: 'true'
paths_ignore: '["**/*.md"]'
paths_filter: |
web:
paths:
- 'web/**/*'
directus:
paths:
- 'directus/**/*'
chatwoot:
paths:
- 'chatwoot/**/*'
- name: Store paths_result output
if: github.event_name != 'push' && steps.skip-check.outputs.paths_result != '{}'
run: echo '${{ steps.skip-check.outputs.paths_result }}' > paths_result
- name: Upload paths_result result
if: github.event_name != 'push' && steps.skip-check.outputs.paths_result != '{}'
uses: actions/upload-artifact@v3
with:
name: paths_result
path: paths_result
- name: Map images
uses: actions/github-script@v6
id: map-images
env:
SKIPPED_BY: ${{ steps.skip-check.outputs.skipped_by }}
PATHS_RESULT: ${{ steps.skip-check.outputs.paths_result }}
with:
script: |
const images = [];
const map = {
web: {
name: 'jaa-web',
context: '.',
file: 'web/Dockerfile'
},
directus: {
name: 'jaa-directus',
context: 'directus',
file: 'Dockerfile'
},
chatwoot: {
name: 'jaa-chatwoot',
context: 'chatwoot',
file: 'Dockerfile'
},
};
let paths_result;
const skipped_by = JSON.parse(process.env.SKIPPED_BY)
if (skipped_by.event) {
if (context.eventName === 'push' && skipped_by.event !== 'push') {
try {
const { data: { artifacts } } = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: skipped_by.runId
});
const artifact = artifacts.find((artifact) => artifact.name === 'paths_result')
const { data } = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip'
});
const { appendFileSync, readFileSync } = require('fs');
appendFileSync('paths_result.zip', Buffer.from(data));
await exec.exec('unzip', ['paths_result.zip']);
paths_result = JSON.parse(readFileSync('paths_result').toString());
} catch (error) {
core.warning(error);
}
} else {
return images;
}
} else {
paths_result = JSON.parse(process.env.PATHS_RESULT);
}
if (paths_result) {
for (const filter in paths_result) {
if (!paths_result[filter].should_skip && filter in map) {
images.push(map[filter]);
}
}
} else {
for (const name in map) {
images.push(map[name]);
}
}
return images;
build-images:
name: Build Images
needs: pre-check
uses: ./.github/workflows/build-images.yml
with:
images: ${{ needs.pre-check.outputs.images }}
push: ${{ github.event_name == 'push' }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}