Skip to content

Commit

Permalink
fix file owners
Browse files Browse the repository at this point in the history
  • Loading branch information
yylyyl committed Oct 19, 2023
1 parent 135d8da commit 426eb74
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 14 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const io = require('@actions/io')
const core = require('@actions/core')
const { Podman } = require('./podman')
const { savePodmanImageCache } = require('./cache')
const { fixOwner } = require('./temp')

async function cleanup() {
try {
Expand All @@ -11,6 +12,8 @@ async function cleanup() {

const podmanContainer = podman.getContainer('podmaninpodman')
await podmanContainer.remove(true)

await fixOwner()
} catch (error) {
// Fail the workflow run if an error occurs
core.setFailed(error.message)
Expand Down
14 changes: 11 additions & 3 deletions src/temp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ const io = require('@actions/io')
const path = require('path')
const exec = require('@actions/exec')

const tmp = path.join(process.env.RUNNER_TEMP, 'podman-in-podman-build')
let temDirCreated = false

async function tempDir() {
const tmp = path.join(process.env.RUNNER_TEMP, 'podman-in-podman-build')

if (!temDirCreated) {
await io.mkdirP(tmp)
await exec.exec(await io.which('chmod', true), ['777', tmp])
Expand All @@ -16,4 +15,13 @@ async function tempDir() {
return tmp
}

module.exports = { tempDir }
async function fixOwner() {
await exec.exec(await io.which('sudo', true), [
'chown',
'-R',
process.env.USER,
tmp
])
}

module.exports = { tempDir, fixOwner }

0 comments on commit 426eb74

Please sign in to comment.