Skip to content

Commit ccb34b9

Browse files
committed
apt.js - always run update
1 parent 309cf36 commit ccb34b9

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Installs Bundler using the code from [ruby/setup-ruby].
3636
3737
### apt: (Ubuntu)
3838
39-
List of packages to install. Space delimited. Special options are `_update_` and `_upgrade_`.
39+
List of packages to install. Space delimited. Including `_upgrade_` will do so. `update` is always done.
4040

4141
### brew: (macOS)
4242

apt.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ const { execSync } = require('./common')
88
let apt = core.getInput('apt-get').replace(/[^a-z_ \d.-]+/gi, '').trim().toLowerCase()
99

1010
export const run = async () => {
11+
let needUpdate = true
1112
try {
1213
if (apt !== '') {
13-
if (apt.includes('_update_')) {
14-
execSync('sudo apt-get -qy update')
15-
apt = apt.replace(/\b_update_\b/gi, '').trim()
16-
}
1714

1815
if (apt.includes('_upgrade_')) {
1916
execSync('sudo apt-get -qy update')
17+
needUpdate = false
2018
execSync('sudo apt-get -qy dist-upgrade')
2119
apt = apt.replace(/\b_upgrade_\b/gi, '').trim()
2220
}
2321

2422
if (apt !== '') {
23+
if (needUpdate) { execSync('sudo apt-get -qy update') }
2524
execSync(`sudo apt-get -qy --no-install-recommends install ${apt}`)
2625
}
2726
}

dist/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,19 @@ const { execSync } = __webpack_require__(498)
6868
let apt = core.getInput('apt-get').replace(/[^a-z_ \d.-]+/gi, '').trim().toLowerCase()
6969

7070
const run = async () => {
71+
let needUpdate = true
7172
try {
7273
if (apt !== '') {
73-
if (apt.includes('_update_')) {
74-
execSync('sudo apt-get -qy update')
75-
apt = apt.replace(/\b_update_\b/gi, '').trim()
76-
}
7774

7875
if (apt.includes('_upgrade_')) {
7976
execSync('sudo apt-get -qy update')
77+
needUpdate = false
8078
execSync('sudo apt-get -qy dist-upgrade')
8179
apt = apt.replace(/\b_upgrade_\b/gi, '').trim()
8280
}
8381

8482
if (apt !== '') {
83+
if (needUpdate) { execSync('sudo apt-get -qy update') }
8584
execSync(`sudo apt-get -qy --no-install-recommends install ${apt}`)
8685
}
8786
}

0 commit comments

Comments
 (0)