Skip to content

Commit

Permalink
Merge branch 'main' into 7-fix-add-missing-container-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
gmpinder authored Feb 3, 2024
2 parents 670b333 + 9d117b5 commit 9fbff7d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,16 @@ jobs:
runs-on: ubuntu-latest

steps:
# There is a bug selecting a satellite in version 0.8
# so we use 0.7 to login and connect to the satellite
# before switching to the latest version
- uses: earthly/actions-setup@v1
with:
version: v0.7.23
version: v0.8.3

- name: Earthly login
run: |
earthly account login --token ${{ secrets.EARTHLY_SAT_TOKEN }} >> /dev/null
earthly org s blue-build
earthly sat s blue-build-pr
- uses: earthly/actions-setup@v1

with:
version: v0.8.2

- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.ref }}
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,16 @@ jobs:
runs-on: ubuntu-latest

steps:
# There is a bug selecting a satellite in version 0.8
# so we use 0.7 to login and connect to the satellite
# before switching to the latest version
- uses: earthly/actions-setup@v1
with:
version: v0.7.23
version: v0.8.3

- name: Earthly login
run: |
earthly account login --token ${{ secrets.EARTHLY_SAT_TOKEN }} >> /dev/null
earthly org s blue-build
earthly sat s blue-build
- uses: earthly/actions-setup@v1
with:
version: v0.8.2

# Setup repo and add caching
- uses: actions/checkout@v4
with:
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,14 @@ jobs:
# before switching to the latest version
- uses: earthly/actions-setup@v1
with:
version: v0.7.23
version: v0.8.3

- name: Earthly login
run: |
earthly account login --token ${{ secrets.EARTHLY_SAT_TOKEN }} >> /dev/null
earthly org s blue-build
earthly sat s blue-build
- uses: earthly/actions-setup@v1
with:
version: v0.8.2

- name: Set up Python
uses: actions/setup-python@v5
- name: Add tomlq
Expand Down
25 changes: 22 additions & 3 deletions src/commands/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fn running_gitlab_actions() -> bool {
}

#[must_use]
pub fn get_containerfile_list(module: &Module) -> Option<Vec<String>> {
fn get_containerfile_list(module: &Module) -> Option<Vec<String>> {
if module.module_type.as_ref()? == "containerfile" {
Some(
module
Expand All @@ -135,7 +135,7 @@ pub fn get_containerfile_list(module: &Module) -> Option<Vec<String>> {
}

#[must_use]
pub fn print_containerfile(containerfile: &str) -> String {
fn print_containerfile(containerfile: &str) -> String {
debug!("print_containerfile({containerfile})");
debug!("Loading containerfile contents for {containerfile}");

Expand All @@ -152,7 +152,7 @@ pub fn print_containerfile(containerfile: &str) -> String {
}

#[must_use]
pub fn template_module_from_file(file_name: &str) -> String {
fn template_module_from_file(file_name: &str) -> String {
debug!("get_module_from_file({file_name})");

let file_path = PathBuf::from("config").join(file_name);
Expand Down Expand Up @@ -195,3 +195,22 @@ fn print_module_context(module: &Module) -> String {
process::exit(1);
})
}

fn get_files_list(module: &Module) -> Option<Vec<(String, String)>> {
Some(
module
.config
.get("files")?
.as_sequence()?
.iter()
.filter_map(|entry| entry.as_mapping())
.flatten()
.filter_map(|(src, dest)| {
Some((
format!("./config/files/{}", src.as_str()?),
dest.as_str()?.to_string(),
))
})
.collect(),
)
}
6 changes: 6 additions & 0 deletions templates/Containerfile.module
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
{{ self::print_containerfile(c) }}
{%- endfor %}
{%- endif %}
{%- else if type == "files" %}
{%- if let Some(files) = self::get_files_list(module) %}
{%- for (src, dest) in files %}
COPY {{ src }} {{ dest }}
{%- endfor %}
{%- endif %}
{%- else %}
RUN chmod +x /tmp/modules/{{ type }}/{{ type }}.sh && source /tmp/exports.sh && /tmp/modules/{{ type }}/{{ type }}.sh '{{ self::print_module_context(module) }}'
{%- endif %}
Expand Down

0 comments on commit 9fbff7d

Please sign in to comment.